diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java index 3c90c2429ce7..1707915b8804 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java @@ -108,7 +108,8 @@ public class ExceptionUtil { } else if (element instanceof PsiResourceVariable) { final PsiResourceVariable variable = (PsiResourceVariable)element; - final List types = getCloserExceptions(variable); + final List types = ContainerUtil.newArrayList(); + addExceptions(types, getCloserExceptions(variable)); final PsiExpression initializer = variable.getInitializer(); if (initializer != null) addExceptions(types, getThrownExceptions(initializer)); return types; @@ -122,13 +123,13 @@ public class ExceptionUtil { PsiResourceList resourceList = tryStatement.getResourceList(); if (resourceList != null) { for (PsiResourceVariable variable : resourceList.getResourceVariables()) { - array.addAll(getUnhandledCloserExceptions(variable, resourceList)); + addExceptions(array, getUnhandledCloserExceptions(variable, resourceList)); } } PsiCodeBlock tryBlock = tryStatement.getTryBlock(); if (tryBlock != null) { - array.addAll(getThrownExceptions(tryBlock)); + addExceptions(array, getThrownExceptions(tryBlock)); } for (PsiParameter parameter : tryStatement.getCatchBlockParameters()) { @@ -155,7 +156,7 @@ public class ExceptionUtil { int completionReasons = ControlFlowUtil.getCompletionReasons(flow, 0, flow.getSize()); List thrownExceptions = getThrownExceptions(finallyBlock); if ((completionReasons & ControlFlowUtil.NORMAL_COMPLETION_REASON) == 0) { - array = new ArrayList(thrownExceptions); + array = ContainerUtil.newArrayList(thrownExceptions); } else { addExceptions(array, thrownExceptions); @@ -285,11 +286,13 @@ public class ExceptionUtil { if (element instanceof PsiResourceVariable) { final List unhandled = getUnhandledCloserExceptions((PsiResourceVariable)element, topElement); - if (unhandledExceptions == null) { - unhandledExceptions = unhandled; - } - else { - unhandledExceptions.addAll(unhandled); + if (!unhandled.isEmpty()) { + if (unhandledExceptions == null) { + unhandledExceptions = ContainerUtil.newArrayList(unhandled); + } + else { + unhandledExceptions.addAll(unhandled); + } } } diff --git a/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java index 7e854695b890..bcf67ceed089 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java @@ -3,12 +3,12 @@ package org.jetbrains.jps.model.library.impl; import com.intellij.openapi.util.io.FileUtilRt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jps.util.JpsPathUtil; import org.jetbrains.jps.model.*; -import org.jetbrains.jps.model.impl.JpsElementCollectionImpl; import org.jetbrains.jps.model.ex.JpsElementCollectionRole; import org.jetbrains.jps.model.ex.JpsNamedCompositeElementBase; +import org.jetbrains.jps.model.impl.JpsElementCollectionImpl; import org.jetbrains.jps.model.library.*; +import org.jetbrains.jps.util.JpsPathUtil; import java.io.File; import java.util.ArrayList; @@ -20,7 +20,7 @@ import java.util.List; */ public class JpsLibraryImpl

extends JpsNamedCompositeElementBase> implements JpsTypedLibrary

{ private final JpsLibraryType

myLibraryType; - + public JpsLibraryImpl(@NotNull String name, @NotNull JpsLibraryType

type, @NotNull P properties) { super(name); myLibraryType = type; @@ -157,7 +157,8 @@ public class JpsLibraryImpl

extends JpsNamedCompositeEleme collectArchives(child, recursively, result); } } - else if (extension.equals("jar") || extension.equals("zip")) { + // todo [nik] get list of extensions mapped to Archive file type from IDE settings + else if (extension.equals("jar") || extension.equals("zip") || extension.equals("swc") || extension.equals("ane")) { result.add(JpsPathUtil.getLibraryRootUrl(child)); } } diff --git a/platform/core-api/src/com/intellij/openapi/vfs/LocalFileProvider.java b/platform/core-api/src/com/intellij/openapi/vfs/LocalFileProvider.java new file mode 100644 index 000000000000..13ec237e68d1 --- /dev/null +++ b/platform/core-api/src/com/intellij/openapi/vfs/LocalFileProvider.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.vfs; + +import org.jetbrains.annotations.Nullable; + +/** + * To be used for those non-LocalFileSystems which can provide corresponding + * LocalFileSystem file for their element + */ +public interface LocalFileProvider{ + + @Nullable + VirtualFile getLocalVirtualFileFor(@Nullable VirtualFile entryVFile); +} diff --git a/platform/core-api/src/com/intellij/util/PathUtil.java b/platform/core-api/src/com/intellij/util/PathUtil.java index 1c1973986d00..95d4caf034be 100644 --- a/platform/core-api/src/com/intellij/util/PathUtil.java +++ b/platform/core-api/src/com/intellij/util/PathUtil.java @@ -18,6 +18,7 @@ package com.intellij.util; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.LocalFileProvider; import com.intellij.openapi.vfs.StandardFileSystems; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; @@ -50,10 +51,10 @@ public class PathUtil { if (!file.isValid()) { return file; } - if (file.getFileSystem().getProtocol().equals(StandardFileSystems.JAR_PROTOCOL)) { - final VirtualFile jarFile = StandardFileSystems.getVirtualFileForJar(file); - if (jarFile != null) { - return jarFile; + if (file.getFileSystem() instanceof LocalFileProvider) { + final VirtualFile localFile = ((LocalFileProvider)file.getFileSystem()).getLocalVirtualFileFor(file); + if (localFile != null) { + return localFile; } } return file; diff --git a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleBase.java b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleBase.java index 96f05fbacf94..98650d1632c1 100644 --- a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleBase.java +++ b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleBase.java @@ -167,7 +167,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L if (myActions != null) return myActions; DefaultActionGroup group = new DefaultActionGroup(); - final AnAction[] actions = myConsole.createConsoleActions(); + final AnAction[] actions = getConsole().createConsoleActions(); for (AnAction action : actions) { group.add(action); } @@ -203,7 +203,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L public JComponent getComponent() { if (!myWasInitialized) { myWasInitialized = true; - add(myConsole.getComponent(), BorderLayout.CENTER); + add(getConsole().getComponent(), BorderLayout.CENTER); add(createToolbar(), BorderLayout.NORTH); } return this; @@ -238,9 +238,11 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L public void dispose() { myModel.removeFilterListener(this); stopRunning(false); - if (myConsole != null) { - Disposer.dispose(myConsole); - myConsole = null; + synchronized (this) { + if (myConsole != null) { + Disposer.dispose(myConsole); + myConsole = null; + } } if (myFilter != null) { myFilter.dispose(); @@ -342,7 +344,8 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L @Nullable private Editor getEditor() { - return myConsole != null ? PlatformDataKeys.EDITOR.getData((DataProvider) myConsole) : null; + final ConsoleView console = getConsole(); + return console != null ? PlatformDataKeys.EDITOR.getData((DataProvider) console) : null; } private void filterConsoleOutput() { @@ -386,7 +389,8 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L } private synchronized void doFilter() { - myConsole.clear(); + final ConsoleView console = getConsole(); + console.clear(); myModel.processingStarted(); final String[] lines = myOriginalDocument.toString().split("\n"); @@ -410,20 +414,21 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L // we need this, because, document can change before actual scrolling, so offset may be already not at the end if (caretPositioned) { - myConsole.scrollTo(offset); + console.scrollTo(offset); } else { - ((ConsoleViewImpl)myConsole).requestScrollingToEnd(); + ((ConsoleViewImpl)console).requestScrollingToEnd(); } } private int printMessageToConsole(String line) { + final ConsoleView console = getConsole(); if (myContentPreprocessor != null) { List fragments = myContentPreprocessor.parseLogLine(line + '\n'); for (LogFragment fragment : fragments) { ConsoleViewContentType consoleViewType = ConsoleViewContentType.getConsoleViewType(fragment.getOutputType()); if (consoleViewType != null) { - myConsole.print(fragment.getText(), consoleViewType); + console.print(fragment.getText(), consoleViewType); } } return line.length() + 1; @@ -437,9 +442,9 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L if (type != null) { final String messagePrefix = processingResult.getMessagePrefix(); if (messagePrefix != null) { - myConsole.print(messagePrefix, type); + console.print(messagePrefix, type); } - myConsole.print(line + "\n", type); + console.print(line + "\n", type); return (messagePrefix != null ? messagePrefix.length() : 0) + line.length() + 1; } } @@ -449,7 +454,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L } @NotNull - public ConsoleView getConsole() { + public synchronized ConsoleView getConsole() { return myConsole; } @@ -462,11 +467,11 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L } public JComponent getToolbarContextComponent() { - return myConsole.getComponent(); + return getConsole().getComponent(); } public JComponent getPreferredFocusableComponent() { - return myConsole.getPreferredFocusableComponent(); + return getConsole().getPreferredFocusableComponent(); } public String getTitle() { @@ -474,7 +479,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L } public synchronized void clear() { - myConsole.clear(); + getConsole().clear(); myOriginalDocument = null; } diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/JarFileSystem.java b/platform/platform-api/src/com/intellij/openapi/vfs/JarFileSystem.java index cf066b254337..b7da3012ee30 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/JarFileSystem.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/JarFileSystem.java @@ -1,44 +1,50 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.vfs; - -import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; - -public abstract class JarFileSystem extends NewVirtualFileSystem implements JarCopyingFileSystem { - @NonNls public static final String PROTOCOL = StandardFileSystems.JAR_PROTOCOL; - @NonNls public static final String PROTOCOL_PREFIX = "jar://"; - @NonNls public static final String JAR_SEPARATOR = StandardFileSystems.JAR_SEPARATOR; - - public static JarFileSystem getInstance(){ - return (JarFileSystem)VirtualFileManager.getInstance().getFileSystem(PROTOCOL); - } - - @Nullable - public abstract VirtualFile getVirtualFileForJar(@Nullable VirtualFile entryVFile); - @Nullable - public abstract JarFile getJarFile(VirtualFile entryVFile) throws IOException; - - @SuppressWarnings("MethodMayBeStatic") - @Nullable - public VirtualFile getJarRootForLocalFile(@NotNull VirtualFile virtualFile) { - return StandardFileSystems.getJarRootForLocalFile(virtualFile); - } +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.vfs; + +import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.IOException; + +public abstract class JarFileSystem extends NewVirtualFileSystem implements JarCopyingFileSystem, LocalFileProvider { + @NonNls public static final String PROTOCOL = StandardFileSystems.JAR_PROTOCOL; + @NonNls public static final String PROTOCOL_PREFIX = "jar://"; + @NonNls public static final String JAR_SEPARATOR = StandardFileSystems.JAR_SEPARATOR; + + public static JarFileSystem getInstance(){ + return (JarFileSystem)VirtualFileManager.getInstance().getFileSystem(PROTOCOL); + } + + @Nullable + public abstract VirtualFile getVirtualFileForJar(@Nullable VirtualFile entryVFile); + @Nullable + public abstract JarFile getJarFile(VirtualFile entryVFile) throws IOException; + + @SuppressWarnings("MethodMayBeStatic") + @Nullable + public VirtualFile getJarRootForLocalFile(@NotNull VirtualFile virtualFile) { + return StandardFileSystems.getJarRootForLocalFile(virtualFile); + } + + @Nullable + @Override + public VirtualFile getLocalVirtualFileFor(@Nullable VirtualFile entryVFile) { + return getVirtualFileForJar(entryVFile); + } } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java index 268b5fa6c288..e743e6679599 100644 --- a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java @@ -1228,6 +1228,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui, SwingConstants { add(myContent); + disposeCloseButton(); myCloseRec = new CloseButton(); } @@ -1327,16 +1328,20 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui, SwingConstants { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - if (myCloseRec != null && myCloseRec.getParent() != null) { - Container parent = myCloseRec.getParent(); - parent.remove(myCloseRec); - ((JComponent)parent).revalidate(); - parent.repaint(); - } + disposeCloseButton(); } }); } + private void disposeCloseButton() { + if (myCloseRec != null && myCloseRec.getParent() != null) { + Container parent = myCloseRec.getParent(); + parent.remove(myCloseRec); + ((JComponent)parent).revalidate(); + parent.repaint(); + } + } + public void setAlpha(float alpha) { myAlpha = alpha; paintImmediately(0, 0, getWidth(), getHeight());