mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
external compiler: unused classes removed
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
package org.jetbrains.jps.builders.util
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.util.io.ZipUtil
|
||||
import junit.framework.Assert
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class FileSystemItem {
|
||||
boolean directory = false
|
||||
boolean archive = false
|
||||
String name
|
||||
String content = null
|
||||
private final Map<String, FileSystemItem> children = [:]
|
||||
|
||||
FileSystemItem leftShift(FileSystemItem item) {
|
||||
assert !children.containsKey(item.getName()) : "${item.name} already added"
|
||||
children[item.name] = item
|
||||
return this
|
||||
}
|
||||
|
||||
def assertDirectoryEqual(File file, String relativePath) throws IOException {
|
||||
Set<String> notFound = new HashSet<String>(children.keySet());
|
||||
file.listFiles()?.each {File child ->
|
||||
final def name = child.name
|
||||
final def item = children[name]
|
||||
Assert.assertNotNull("unexpected file: $relativePath$name", item)
|
||||
item.assertFileEqual(child, relativePath + name + "/")
|
||||
notFound.remove(name)
|
||||
}
|
||||
Assert.assertTrue("files $notFound not found in $relativePath", notFound.isEmpty());
|
||||
}
|
||||
|
||||
def assertFileEqual(File file, String relativePath) throws IOException {
|
||||
Assert.assertEquals("in $relativePath", name, file.name);
|
||||
if (archive) {
|
||||
final File dirForExtracted = FileUtil.createTempDirectory("extracted_archive", "");
|
||||
ZipUtil.extract(file, dirForExtracted, null);
|
||||
assertDirectoryEqual(dirForExtracted, relativePath);
|
||||
}
|
||||
else if (directory) {
|
||||
Assert.assertTrue("$relativePath${file.name} is not a directory", file.isDirectory());
|
||||
assertDirectoryEqual(file, relativePath);
|
||||
}
|
||||
else if (content != null) {
|
||||
final String actualContent = FileUtil.loadFile(file);
|
||||
Assert.assertEquals("content mismatch for " + relativePath, content, actualContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package org.jetbrains.jps.builders.util;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author Pavel.Sher
|
||||
* Date: 05.03.2008
|
||||
*/
|
||||
public class TempFiles {
|
||||
private static final File ourCurrentTempDir = new File(System.getProperty("java.io.tmpdir"));
|
||||
private final File myCurrentTempDir;
|
||||
|
||||
private static Random ourRandom;
|
||||
|
||||
static {
|
||||
ourRandom = new Random();
|
||||
ourRandom.setSeed(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private final List<File> myFilesToDelete = new ArrayList<File>();
|
||||
|
||||
public TempFiles() {
|
||||
myCurrentTempDir = ourCurrentTempDir;
|
||||
if (!myCurrentTempDir.isDirectory()) {
|
||||
throw new IllegalStateException("Temp directory is not a directory, was deleted by some process: " + myCurrentTempDir.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
private File doCreateTempDir(String prefix, String suffix) throws IOException {
|
||||
prefix = prefix == null ? "" : prefix;
|
||||
suffix = suffix == null ? ".tmp" : suffix;
|
||||
|
||||
do {
|
||||
int count = ourRandom.nextInt();
|
||||
final File f = new File(myCurrentTempDir, prefix + count + suffix);
|
||||
if (!f.exists() && f.mkdirs()) {
|
||||
return f.getCanonicalFile();
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
private File doCreateTempFile(String prefix, String suffix) throws IOException {
|
||||
final File file = doCreateTempDir(prefix, suffix);
|
||||
file.delete();
|
||||
file.createNewFile();
|
||||
return file;
|
||||
}
|
||||
|
||||
public final File createTempFile() throws IOException {
|
||||
File tempFile = doCreateTempFile("test", null);
|
||||
registerAsTempFile(tempFile);
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
private void registerAsTempFile(final File tempFile) {
|
||||
myFilesToDelete.add(tempFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a File object for created temp directory.
|
||||
*
|
||||
* @return a File object for created temp directory
|
||||
* @throws IOException if directory creation fails.
|
||||
*/
|
||||
public final File createTempDir() throws IOException {
|
||||
File f = doCreateTempDir("test", "");
|
||||
registerAsTempFile(f);
|
||||
return f;
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
for (File file : myFilesToDelete) {
|
||||
if (file.exists()) {
|
||||
FileUtil.delete(file);
|
||||
}
|
||||
}
|
||||
myFilesToDelete.clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user