Merge remote-tracking branch 'origin/master'

This commit is contained in:
Vassiliy Kudryashov
2012-11-06 21:04:17 +04:00
7 changed files with 131 additions and 82 deletions
@@ -108,7 +108,8 @@ public class ExceptionUtil {
}
else if (element instanceof PsiResourceVariable) {
final PsiResourceVariable variable = (PsiResourceVariable)element;
final List<PsiClassType> types = getCloserExceptions(variable);
final List<PsiClassType> 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<PsiClassType> thrownExceptions = getThrownExceptions(finallyBlock);
if ((completionReasons & ControlFlowUtil.NORMAL_COMPLETION_REASON) == 0) {
array = new ArrayList<PsiClassType>(thrownExceptions);
array = ContainerUtil.newArrayList(thrownExceptions);
}
else {
addExceptions(array, thrownExceptions);
@@ -285,11 +286,13 @@ public class ExceptionUtil {
if (element instanceof PsiResourceVariable) {
final List<PsiClassType> 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);
}
}
}
@@ -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<P extends JpsElement> extends JpsNamedCompositeElementBase<JpsLibraryImpl<P>> implements JpsTypedLibrary<P> {
private final JpsLibraryType<P> myLibraryType;
public JpsLibraryImpl(@NotNull String name, @NotNull JpsLibraryType<P> type, @NotNull P properties) {
super(name);
myLibraryType = type;
@@ -157,7 +157,8 @@ public class JpsLibraryImpl<P extends JpsElement> 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));
}
}
@@ -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);
}
@@ -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;
@@ -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<LogFragment> 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;
}
@@ -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);
}
}
@@ -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());