mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (duplicates; formatting; typos)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -13,11 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* created at Jan 3, 2002
|
||||
* @author Jeka
|
||||
*/
|
||||
package com.intellij.compiler.impl;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
@@ -38,6 +33,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Jeka
|
||||
* @since Jan 3, 2002
|
||||
*/
|
||||
public class CompilerUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.CompilerUtil");
|
||||
|
||||
@@ -49,10 +48,6 @@ public class CompilerUtil {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* must not be called inside ReadAction
|
||||
* @param files
|
||||
*/
|
||||
public static void refreshIOFiles(@NotNull final Collection<File> files) {
|
||||
if (!files.isEmpty()) {
|
||||
LocalFileSystem.getInstance().refreshIoFiles(files);
|
||||
@@ -60,16 +55,8 @@ public class CompilerUtil {
|
||||
}
|
||||
|
||||
public static void refreshIODirectories(@NotNull final Collection<File> files) {
|
||||
final LocalFileSystem lfs = LocalFileSystem.getInstance();
|
||||
final List<VirtualFile> filesToRefresh = new ArrayList<VirtualFile>();
|
||||
for (File file : files) {
|
||||
final VirtualFile virtualFile = lfs.refreshAndFindFileByIoFile(file);
|
||||
if (virtualFile != null) {
|
||||
filesToRefresh.add(virtualFile);
|
||||
}
|
||||
}
|
||||
if (!filesToRefresh.isEmpty()) {
|
||||
RefreshQueue.getInstance().refresh(false, true, null, filesToRefresh);
|
||||
if (!files.isEmpty()) {
|
||||
LocalFileSystem.getInstance().refreshIoFiles(files, false, true, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -376,12 +376,7 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
|
||||
String fullTargetPath = getAbsolutePath(relativeTargetPath);
|
||||
File target = new File(fullTargetPath);
|
||||
try {
|
||||
if (source.isDirectory()) {
|
||||
FileUtil.copyDir(source, target);
|
||||
}
|
||||
else {
|
||||
FileUtil.copy(source, target);
|
||||
}
|
||||
FileUtil.copyFileOrDir(source, target);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -17,17 +17,14 @@ package com.intellij.openapi.application;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class RunResult<T> extends Result<T> {
|
||||
|
||||
private BaseActionRunnable<T> myActionRunnable;
|
||||
|
||||
private Throwable myThrowable;
|
||||
|
||||
protected RunResult() {
|
||||
}
|
||||
protected RunResult() { }
|
||||
|
||||
public RunResult(@NotNull BaseActionRunnable<T> action) {
|
||||
myActionRunnable = action;
|
||||
@@ -38,18 +35,13 @@ public class RunResult<T> extends Result<T> {
|
||||
myActionRunnable.run(this);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e; // this exception may occur from time to time and it shouldn't be catched
|
||||
throw e; // this exception may occur from time to time and it shouldn't be caught
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
myThrowable = throwable;
|
||||
catch (Throwable t) {
|
||||
myThrowable = t;
|
||||
if (!myActionRunnable.isSilentExecution()) {
|
||||
if (throwable instanceof RuntimeException) throw (RuntimeException)throwable;
|
||||
if (throwable instanceof Error) {
|
||||
throw (Error)throwable;
|
||||
}
|
||||
else {
|
||||
throw new RuntimeException(myThrowable);
|
||||
}
|
||||
ExceptionUtil.rethrowUnchecked(t);
|
||||
throw new RuntimeException(myThrowable);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -65,7 +57,7 @@ public class RunResult<T> extends Result<T> {
|
||||
|
||||
@NotNull
|
||||
public RunResult logException(Logger logger) {
|
||||
if (hasException()) {
|
||||
if (myThrowable != null) {
|
||||
logger.error(myThrowable);
|
||||
}
|
||||
|
||||
@@ -74,16 +66,11 @@ public class RunResult<T> extends Result<T> {
|
||||
|
||||
@NotNull
|
||||
public RunResult<T> throwException() throws RuntimeException, Error {
|
||||
if (hasException()) {
|
||||
if (myThrowable instanceof RuntimeException) {
|
||||
throw (RuntimeException)myThrowable;
|
||||
}
|
||||
if (myThrowable instanceof Error) {
|
||||
throw (Error)myThrowable;
|
||||
}
|
||||
|
||||
if (myThrowable != null) {
|
||||
ExceptionUtil.rethrowUnchecked(myThrowable);
|
||||
throw new RuntimeException(myThrowable);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -23,8 +23,10 @@ import javax.swing.*;
|
||||
|
||||
public abstract class WriteAction<T> extends BaseActionRunnable<T> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.application.WriteAction");
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@SuppressWarnings("InstanceofCatchParameter")
|
||||
public RunResult<T> execute() {
|
||||
final RunResult<T> result = new RunResult<T>(this);
|
||||
|
||||
@@ -35,7 +37,8 @@ public abstract class WriteAction<T> extends BaseActionRunnable<T> {
|
||||
}
|
||||
|
||||
try {
|
||||
if (!application.isDispatchThread() && application.isReadAccessAllowed()) {
|
||||
boolean dispatchThread = application.isDispatchThread();
|
||||
if (!dispatchThread && application.isReadAccessAllowed()) {
|
||||
LOG.error("Must not start write action from within read action in the other thread - deadlock is coming");
|
||||
}
|
||||
Runnable runnable = new Runnable() {
|
||||
@@ -49,7 +52,7 @@ public abstract class WriteAction<T> extends BaseActionRunnable<T> {
|
||||
});
|
||||
}
|
||||
};
|
||||
if (application.isDispatchThread()) {
|
||||
if (dispatchThread) {
|
||||
runnable.run();
|
||||
}
|
||||
else if (application.isReadAccessAllowed()) {
|
||||
@@ -68,6 +71,7 @@ public abstract class WriteAction<T> extends BaseActionRunnable<T> {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -533,6 +533,18 @@ public class VfsUtil extends VfsUtilCore {
|
||||
return children == null ? VirtualFile.EMPTY_ARRAY : children;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<VirtualFile> getChildren(@NotNull VirtualFile dir, @NotNull VirtualFileFilter filter) {
|
||||
List<VirtualFile> result = null;
|
||||
for (VirtualFile child : dir.getChildren()) {
|
||||
if (filter.accept(child)) {
|
||||
if (result == null) result = ContainerUtil.newSmartList();
|
||||
result.add(child);
|
||||
}
|
||||
}
|
||||
return result != null ? result : ContainerUtil.<VirtualFile>emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url Url for virtual file
|
||||
* @return url for parent directory of virtual file
|
||||
|
||||
+1
-6
@@ -623,12 +623,7 @@ public abstract class LocalFileSystemBase extends LocalFileSystem {
|
||||
if (!auxCopy(file, newParent, copyName)) {
|
||||
try {
|
||||
File ioFile = convertToIOFile(file);
|
||||
if (attributes.isDirectory()) {
|
||||
FileUtil.copyDir(ioFile, ioTarget);
|
||||
}
|
||||
else {
|
||||
FileUtil.copy(ioFile, ioTarget);
|
||||
}
|
||||
FileUtil.copyFileOrDir(ioFile, ioTarget, attributes.isDirectory());
|
||||
}
|
||||
catch (IOException e) {
|
||||
FileUtil.delete(ioTarget);
|
||||
|
||||
@@ -540,6 +540,19 @@ public class FileUtil extends FileUtilRt {
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyFileOrDir(@NotNull File from, @NotNull File to) throws IOException {
|
||||
copyFileOrDir(from, to, from.isDirectory());
|
||||
}
|
||||
|
||||
public static void copyFileOrDir(@NotNull File from, @NotNull File to, boolean isDir) throws IOException {
|
||||
if (isDir) {
|
||||
copyDir(from, to);
|
||||
}
|
||||
else {
|
||||
copy(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyDir(@NotNull File fromDir, @NotNull File toDir) throws IOException {
|
||||
copyDir(fromDir, toDir, true);
|
||||
}
|
||||
@@ -555,13 +568,7 @@ public class FileUtil extends FileUtilRt {
|
||||
public static void copyDirContent(@NotNull File fromDir, @NotNull File toDir) throws IOException {
|
||||
File[] children = ObjectUtils.notNull(fromDir.listFiles(), ArrayUtil.EMPTY_FILE_ARRAY);
|
||||
for (File child : children) {
|
||||
File target = new File(toDir, child.getName());
|
||||
if (child.isFile()) {
|
||||
copy(child, target);
|
||||
}
|
||||
else {
|
||||
copyDir(child, target, true);
|
||||
}
|
||||
copyFileOrDir(child, new File(toDir, child.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-6
@@ -18,7 +18,6 @@ package org.jetbrains.plugins.javaFX.packaging;
|
||||
import com.intellij.execution.CommandLineUtil;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
@@ -137,11 +136,7 @@ public abstract class AbstractJavaFxPackager {
|
||||
final String fileName = file.getName();
|
||||
if (ArrayUtilRt.find(generatedItems, fileName) < 0) {
|
||||
final File destination = new File(tempUnzippedArtifactOutput, fileName);
|
||||
if (file.isFile()) {
|
||||
FileUtil.copy(file, destination);
|
||||
} else {
|
||||
FileUtil.copyDir(file, destination, true);
|
||||
}
|
||||
FileUtil.copyFileOrDir(file, destination);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -337,7 +337,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
|
||||
// check destination directory
|
||||
if (isUnversioned(vcs, dst.getParentFile())) {
|
||||
try {
|
||||
copyFileOrDir(src, dst);
|
||||
FileUtil.copyFileOrDir(src, dst);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new SvnBindException(e);
|
||||
@@ -369,7 +369,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
|
||||
File newFile = new File(dst, relativePath);
|
||||
if (!newFile.exists()) {
|
||||
try {
|
||||
copyFileOrDir(src, dst);
|
||||
FileUtil.copyFileOrDir(src, dst);
|
||||
}
|
||||
catch (IOException e) {
|
||||
exc[0] = new SvnBindException(e);
|
||||
@@ -385,14 +385,6 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyFileOrDir(File src, File dst) throws IOException {
|
||||
if (src.isDirectory()) {
|
||||
FileUtil.copyDir(src, dst);
|
||||
} else {
|
||||
FileUtil.copy(src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean doUsualMove(SvnVcs vcs, File src) {
|
||||
// if src is not under version control, do usual move.
|
||||
Status srcStatus = getFileStatus(vcs, src);
|
||||
|
||||
Reference in New Issue
Block a user