util-rt module introduced

This commit is contained in:
Roman Shevchenko
2012-03-20 20:45:08 +01:00
parent 87a8ff7033
commit 5d54369378
13 changed files with 381 additions and 141 deletions
+1
View File
@@ -107,6 +107,7 @@
<module fileurl="file://$PROJECT_DIR$/plugins/ui-designer/ui-designer.iml" filepath="$PROJECT_DIR$/plugins/ui-designer/ui-designer.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/platform/usageView/usageView.iml" filepath="$PROJECT_DIR$/platform/usageView/usageView.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/util/util.iml" filepath="$PROJECT_DIR$/platform/util/util.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/util-rt/util-rt.iml" filepath="$PROJECT_DIR$/platform/util-rt/util-rt.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/vcs-api/vcs-api.iml" filepath="$PROJECT_DIR$/platform/vcs-api/vcs-api.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/vcs-impl/vcs-impl.iml" filepath="$PROJECT_DIR$/platform/vcs-impl/vcs-impl.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/xdebugger-api/xdebugger-api.iml" filepath="$PROJECT_DIR$/platform/xdebugger-api/xdebugger-api.iml" group="platform" />
@@ -13,11 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.util.io;
package org.jetbrains.util.rt;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,14 +24,16 @@ import java.io.*;
import java.util.UUID;
/**
* This is a light version of {@link FileUtil}.
* It is used by scripts loaded externally and almost independent of IDEA, so add here as few dependencies as possible.
* Stripped-down version of {@code com.intellij.openapi.util.io.FileUtil}.
* Intended to use by external (out-of-IDE-process) runners and helpers so it should not contain any library dependencies.
*
* @since 12.0
*/
public class FileUtilLight {
private static String ourCanonicalTempPathCache = null;
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
public class FileUtilRt {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.io.FileUtilLight");
private static String ourCanonicalTempPathCache = null;
@NotNull
public static File createTempDirectory(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException {
@@ -55,8 +54,7 @@ public class FileUtilLight {
}
@NotNull
public static File createTempFile(@NonNls final File dir, @NotNull @NonNls String prefix, @Nullable @NonNls String suffix, final boolean create)
throws IOException {
public static File createTempFile(@NonNls File dir, @NotNull @NonNls String prefix, @Nullable @NonNls String suffix, boolean create) throws IOException {
return createTempFile(dir, prefix, suffix, create, true);
}
@@ -122,7 +120,7 @@ public class FileUtilLight {
private static File normalizeFile(File temp) throws IOException {
final File canonical = temp.getCanonicalFile();
return SystemInfo.isWindows && canonical.getAbsolutePath().contains(" ") ? temp.getAbsoluteFile() : canonical;
return SystemInfoRt.isWindows && canonical.getAbsolutePath().contains(" ") ? temp.getAbsoluteFile() : canonical;
}
public static String getTempDirectory() {
@@ -136,7 +134,7 @@ public class FileUtilLight {
final File file = new File(System.getProperty("java.io.tmpdir"));
try {
final String canonical = file.getCanonicalPath();
if (!SystemInfo.isWindows || !canonical.contains(" ")) {
if (!SystemInfoRt.isWindows || !canonical.contains(" ")) {
return canonical;
}
}
@@ -169,7 +167,7 @@ public class FileUtilLight {
*
* @param path the path to use
* @param executableFlag new value of executable attribute
* @throws IOException if there is a problem with setting the flag
* @throws java.io.IOException if there is a problem with setting the flag
*/
public static void setExecutableAttribute(@NotNull String path, boolean executableFlag) throws IOException {
final File file = new File(path);
@@ -189,14 +187,14 @@ public class FileUtilLight {
}
@NotNull
public static String loadFile(@NotNull File file, String encoding) throws IOException {
public static String loadFile(@NotNull File file, @Nullable @NonNls String encoding) throws IOException {
return loadFile(file, encoding, false);
}
@NotNull
public static String loadFile(@NotNull File file, String encoding, boolean convertLineSeparators) throws IOException {
public static String loadFile(@NotNull File file, @Nullable @NonNls String encoding, boolean convertLineSeparators) throws IOException {
final String s = new String(loadFileText(file, encoding));
return convertLineSeparators ? StringUtil.convertLineSeparators(s) : s;
return convertLineSeparators ? StringUtilRt.convertLineSeparators(s) : s;
}
@NotNull
@@ -205,8 +203,9 @@ public class FileUtilLight {
}
@NotNull
public static char[] loadFileText(@NotNull File file, @NonNls String encoding) throws IOException {
public static char[] loadFileText(@NotNull File file, @Nullable @NonNls String encoding) throws IOException {
InputStream stream = new FileInputStream(file);
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
Reader reader = encoding == null ? new InputStreamReader(stream) : new InputStreamReader(stream, encoding);
try {
return loadText(reader, (int)file.length());
@@ -234,5 +233,4 @@ public class FileUtilLight {
return newChars;
}
}
}
@@ -0,0 +1,159 @@
/*
* 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 org.jetbrains.util.rt;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.LogManager;
/**
* A wrapper which uses either IDE logging subsystem (if available) or java.util.logging.
*
* @since 12.0
*/
public abstract class Logger {
private interface Factory {
Logger getInstance(@NotNull @NonNls final String category);
}
private static final Factory ourFactory;
static {
Factory factory;
try {
factory = new IdeaFactory();
}
catch (Exception e) {
factory = new JavaFactory();
}
ourFactory = factory;
}
@NotNull
public static Logger getInstance(@NotNull @NonNls final String category) {
return ourFactory.getInstance(category);
}
public void info(@Nullable @NonNls final String message) {
info(message, null);
}
public void info(@NotNull final Throwable t) {
info(t.getMessage(), t);
}
public void warn(@Nullable @NonNls final String message) {
warn(message, null);
}
public void warn(@NotNull final Throwable t) {
warn(t.getMessage(), t);
}
public void error(@Nullable @NonNls final String message) {
error(message, null);
}
public void error(@NotNull final Throwable t) {
error(t.getMessage(), t);
}
public abstract void info(@Nullable @NonNls final String message, @Nullable final Throwable t);
public abstract void warn(@Nullable @NonNls final String message, @Nullable final Throwable t);
public abstract void error(@Nullable @NonNls final String message, @Nullable final Throwable t);
private static class JavaFactory implements Factory {
private final LogManager myManager = LogManager.getLogManager();
@Override
public Logger getInstance(@NotNull @NonNls final String category) {
final java.util.logging.Logger logger = myManager.getLogger(category);
return new Logger() {
@Override
public void info(@Nullable @NonNls final String message, @Nullable final Throwable t) {
logger.log(Level.INFO, message, t);
}
@Override
public void warn(@Nullable @NonNls final String message, @Nullable final Throwable t) {
logger.log(Level.WARNING, message, t);
}
@Override
public void error(@Nullable @NonNls final String message, @Nullable final Throwable t) {
logger.log(Level.SEVERE, message, t);
}
};
}
}
private static class IdeaFactory implements Factory {
private final Method myGetInstance;
private final Method myInfo;
private final Method myWarn;
private final Method myError;
private IdeaFactory() throws Exception {
final Class<?> loggerClass = Class.forName("com.intellij.openapi.diagnostic.Logger");
myGetInstance = loggerClass.getMethod("getInstance", String.class);
myGetInstance.setAccessible(true);
myInfo = loggerClass.getMethod("info", String.class, Throwable.class);
myInfo.setAccessible(true);
myWarn = loggerClass.getMethod("warn", String.class, Throwable.class);
myInfo.setAccessible(true);
myError = loggerClass.getMethod("error", String.class, Throwable.class);
myError.setAccessible(true);
}
@Override
public Logger getInstance(@NotNull @NonNls final String category) {
try {
final Object logger = myGetInstance.invoke(null, category);
return new Logger() {
@Override
public void info(@Nullable @NonNls final String message, @Nullable final Throwable t) {
try {
myInfo.invoke(logger, message, t);
}
catch (Exception ignored) { }
}
@Override
public void warn(@Nullable @NonNls final String message, @Nullable final Throwable t) {
try {
myWarn.invoke(logger, message, t);
}
catch (Exception ignored) { }
}
@Override
public void error(@Nullable @NonNls final String message, @Nullable final Throwable t) {
try {
myError.invoke(logger, message, t);
}
catch (Exception ignored) { }
}
};
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
@@ -0,0 +1,124 @@
/*
* 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 org.jetbrains.util.rt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Stripped-down version of {@code com.intellij.openapi.util.text.StringUtil}.
* Intended to use by external (out-of-IDE-process) runners and helpers so it should not contain any library dependencies.
*
* @since 12.0
*/
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
public class StringUtilRt {
/**
* Converts line separators to <code>"\n"</code>
*/
@NotNull
public static String convertLineSeparators(@NotNull String text) {
return convertLineSeparators(text, false);
}
@NotNull
public static String convertLineSeparators(@NotNull String text, boolean keepCarriageReturn) {
return convertLineSeparators(text, "\n", null, keepCarriageReturn);
}
@NotNull
public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator) {
return convertLineSeparators(text, newSeparator, null);
}
@NotNull
public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator, @Nullable int[] offsetsToKeep) {
return convertLineSeparators(text, newSeparator, offsetsToKeep, false);
}
@NotNull
public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator, @Nullable int[] offsetsToKeep,
boolean keepCarriageReturn) {
StringBuilder buffer = null;
int intactLength = 0;
final boolean newSeparatorIsSlashN = "\n".equals(newSeparator);
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (c == '\n') {
if (!newSeparatorIsSlashN) {
if (buffer == null) {
buffer = new StringBuilder(text.length());
buffer.append(text, 0, intactLength);
}
buffer.append(newSeparator);
shiftOffsets(offsetsToKeep, buffer.length(), 1, newSeparator.length());
}
else if (buffer == null) {
intactLength++;
}
else {
buffer.append(c);
}
}
else if (c == '\r') {
boolean followedByLineFeed = i < text.length() - 1 && text.charAt(i + 1) == '\n';
if (!followedByLineFeed && keepCarriageReturn) {
if (buffer == null) {
intactLength++;
}
else {
buffer.append(c);
}
continue;
}
if (buffer == null) {
buffer = new StringBuilder(text.length());
buffer.append(text, 0, intactLength);
}
buffer.append(newSeparator);
if (followedByLineFeed) {
//noinspection AssignmentToForLoopParameter
i++;
shiftOffsets(offsetsToKeep, buffer.length(), 2, newSeparator.length());
}
else {
shiftOffsets(offsetsToKeep, buffer.length(), 1, newSeparator.length());
}
}
else {
if (buffer == null) {
intactLength++;
}
else {
buffer.append(c);
}
}
}
return buffer == null ? text : buffer.toString();
}
private static void shiftOffsets(int[] offsets, int changeOffset, int oldLength, int newLength) {
if (offsets == null) return;
int shift = newLength - oldLength;
if (shift == 0) return;
for (int i = 0; i < offsets.length; i++) {
int offset = offsets[i];
if (offset >= changeOffset + oldLength) {
offsets[i] += shift;
}
}
}
}
@@ -0,0 +1,37 @@
/*
* 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 org.jetbrains.util.rt;
/**
* Stripped-down version of {@code com.intellij.openapi.util.SystemInfo}.
* Intended to use by external (out-of-IDE-process) runners and helpers so it should not contain any library dependencies.
*
* @since 12.0
*/
@SuppressWarnings({"HardCodedStringLiteral", "UtilityClassWithoutPrivateConstructor"})
public class SystemInfoRt {
public static final String OS_NAME = System.getProperty("os.name");
public static final String OS_VERSION = System.getProperty("os.version").toLowerCase();
protected static final String _OS_NAME = OS_NAME.toLowerCase();
public static final boolean isWindows = _OS_NAME.startsWith("windows");
public static final boolean isOS2 = _OS_NAME.startsWith("os/2") || _OS_NAME.startsWith("os2");
public static final boolean isMac = _OS_NAME.startsWith("mac");
public static final boolean isLinux = _OS_NAME.startsWith("linux");
public static final boolean isUnix = !isWindows && !isOS2;
public static final boolean isFileSystemCaseSensitive = !isWindows && !isOS2 && !isMac;
}
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="annotations" />
</component>
</module>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
@@ -17,22 +17,22 @@ package com.intellij.openapi.util;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.util.rt.SystemInfoRt;
import java.io.File;
import java.util.List;
@SuppressWarnings({"HardCodedStringLiteral", "UtilityClassWithoutPrivateConstructor", "UnusedDeclaration"})
public class SystemInfo {
public static final String OS_NAME = System.getProperty("os.name");
public static final String OS_VERSION = System.getProperty("os.version").toLowerCase();
public class SystemInfo extends SystemInfoRt {
public static final String OS_NAME = SystemInfoRt.OS_NAME;
public static final String OS_VERSION = SystemInfoRt.OS_VERSION;
public static final String OS_ARCH = System.getProperty("os.arch");
public static final String JAVA_VERSION = System.getProperty("java.version");
public static final String JAVA_RUNTIME_VERSION = System.getProperty("java.runtime.version");
public static final String ARCH_DATA_MODEL = System.getProperty("sun.arch.data.model");
public static final String SUN_DESKTOP = System.getProperty("sun.desktop", "");
private static final String _OS_NAME = OS_NAME.toLowerCase();
public static final boolean isWindows = _OS_NAME.startsWith("windows");
public static final boolean isWindows = SystemInfoRt.isWindows;
public static final boolean isWindowsNT = _OS_NAME.startsWith("windows nt");
public static final boolean isWindows2000 = _OS_NAME.startsWith("windows 2000");
public static final boolean isWindows2003 = _OS_NAME.startsWith("windows 2003");
@@ -40,12 +40,12 @@ public class SystemInfo {
public static final boolean isWindowsVista = _OS_NAME.startsWith("windows vista");
public static final boolean isWindows7 = _OS_NAME.startsWith("windows 7");
public static final boolean isWindows9x = _OS_NAME.startsWith("windows 9") || _OS_NAME.startsWith("windows me");
public static final boolean isOS2 = _OS_NAME.startsWith("os/2") || _OS_NAME.startsWith("os2");
public static final boolean isMac = _OS_NAME.startsWith("mac");
public static final boolean isOS2 = SystemInfoRt.isOS2;
public static final boolean isMac = SystemInfoRt.isMac;
public static final boolean isLinux = SystemInfoRt.isLinux;
public static final boolean isFreeBSD = _OS_NAME.startsWith("freebsd");
public static final boolean isLinux = _OS_NAME.startsWith("linux");
public static final boolean isSolaris = _OS_NAME.startsWith("sunos");
public static final boolean isUnix = !isWindows && !isOS2;
public static final boolean isUnix = SystemInfoRt.isUnix;
private static final String _SUN_DESKTOP = SUN_DESKTOP.toLowerCase();
public static final boolean isKDE = _SUN_DESKTOP.contains("kde");
@@ -55,7 +55,7 @@ public class SystemInfo {
public static final boolean isMacSystemMenu = isMac && "true".equals(System.getProperty("apple.laf.useScreenMenuBar"));
public static final boolean isFileSystemCaseSensitive = !isWindows && !isOS2 && !isMac;
public static final boolean isFileSystemCaseSensitive = SystemInfoRt.isFileSystemCaseSensitive;
public static final boolean areSymLinksSupported = isUnix ||
isWindows && OS_VERSION.compareTo("6.0") >= 0 && isJavaVersionAtLeast("1.7");
@@ -43,7 +43,7 @@ import java.util.*;
import java.util.regex.Pattern;
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
public class FileUtil extends FileUtilLight {
public class FileUtil extends FileUtilRt {
public static final int MEGABYTE = 1024 * 1024;
@NonNls public static final String ASYNC_DELETE_EXTENSION = ".__del__";
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
@@ -27,6 +27,7 @@ import com.intellij.util.text.LineReader;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.util.rt.StringUtilRt;
import java.beans.Introspector;
import java.io.ByteArrayInputStream;
@@ -37,10 +38,12 @@ import java.util.regex.Pattern;
//TeamCity inherits StringUtil: do not add private constructors!!!
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
public class StringUtil {
public class StringUtil extends StringUtilRt {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.text.StringUtil");
@NonNls private static final String VOWELS = "aeiouy";
private static final Pattern EOL_SPLIT_PATTERN = Pattern.compile(" *(\r|\n|\r\n)+ *");
@NonNls private static final Pattern EOL_SPLIT_PATTERN = Pattern.compile(" *(\r|\n|\r\n)+ *");
public static final NotNullFunction<String, String> QUOTER = new NotNullFunction<String, String>() {
@NotNull
public String fun(String s) {
@@ -284,101 +287,6 @@ public class StringUtil {
return "";
}
/**
* Converts line separators to <code>"\n"</code>
*/
@NotNull
public static String convertLineSeparators(@NotNull String text) {
return convertLineSeparators(text, false);
}
@NotNull
public static String convertLineSeparators(@NotNull String text, boolean keepCarriageReturn) {
return convertLineSeparators(text, "\n", null, keepCarriageReturn);
}
@NotNull
public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator) {
return convertLineSeparators(text, newSeparator, null);
}
@NotNull
public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator, @Nullable int[] offsetsToKeep) {
return convertLineSeparators(text, newSeparator, offsetsToKeep, false);
}
@NotNull
public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator, @Nullable int[] offsetsToKeep,
boolean keepCarriageReturn) {
StringBuilder buffer = null;
int intactLength = 0;
final boolean newSeparatorIsSlashN = "\n".equals(newSeparator);
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (c == '\n') {
if (!newSeparatorIsSlashN) {
if (buffer == null) {
buffer = new StringBuilder(text.length());
buffer.append(text, 0, intactLength);
}
buffer.append(newSeparator);
shiftOffsets(offsetsToKeep, buffer.length(), 1, newSeparator.length());
}
else if (buffer == null) {
intactLength++;
}
else {
buffer.append(c);
}
}
else if (c == '\r') {
boolean followedByLineFeed = i < text.length() - 1 && text.charAt(i + 1) == '\n';
if (!followedByLineFeed && keepCarriageReturn) {
if (buffer == null) {
intactLength++;
}
else {
buffer.append(c);
}
continue;
}
if (buffer == null) {
buffer = new StringBuilder(text.length());
buffer.append(text, 0, intactLength);
}
buffer.append(newSeparator);
if (followedByLineFeed) {
i++;
shiftOffsets(offsetsToKeep, buffer.length(), 2, newSeparator.length());
}
else {
shiftOffsets(offsetsToKeep, buffer.length(), 1, newSeparator.length());
}
}
else {
if (buffer == null) {
intactLength++;
}
else {
buffer.append(c);
}
}
}
return buffer == null ? text : buffer.toString();
}
private static void shiftOffsets(int[] offsets, int changeOffset, int oldLength, int newLength) {
if (offsets == null) return;
int shift = newLength - oldLength;
if (shift == 0) return;
for (int i = 0; i < offsets.length; i++) {
int offset = offsets[i];
if (offset >= changeOffset + oldLength) {
offsets[i] += shift;
}
}
}
public static int getLineBreakCount(@NotNull CharSequence text) {
int count = 0;
for (int i = 0; i < text.length(); i++) {
+1
View File
@@ -15,6 +15,7 @@
<orderEntry type="library" name="picocontainer" level="project" />
<orderEntry type="module" module-name="platform-resources-en" />
<orderEntry type="module" module-name="annotations" exported="" />
<orderEntry type="module" module-name="util-rt" exported="" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="library" name="jna" level="project" />
<orderEntry type="library" name="OroMatcher" level="project" />
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -15,7 +15,6 @@
*/
package org.jetbrains.git4idea.ssh;
import com.intellij.openapi.util.io.FileUtilLight;
import com.trilead.ssh2.KnownHosts;
import gnu.trove.THashMap;
import org.apache.commons.codec.DecoderException;
@@ -23,6 +22,7 @@ import org.apache.xmlrpc.XmlRpcClientLite;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.git4idea.util.ScriptGenerator;
import org.jetbrains.util.rt.FileUtilRt;
import java.io.File;
import java.io.IOException;
@@ -66,8 +66,7 @@ public abstract class GitSSHService {
public synchronized File getScriptPath() throws IOException {
if (myScriptPath == null || !myScriptPath.exists()) {
ScriptGenerator generator = new ScriptGenerator(GitSSHHandler.GIT_SSH_PREFIX, SSHMain.class, getTempDir());
generator.addClasses(XmlRpcClientLite.class, DecoderException.class);
generator.addClasses(KnownHosts.class, FileUtilLight.class);
generator.addClasses(XmlRpcClientLite.class, DecoderException.class, KnownHosts.class, FileUtilRt.class);
generator.addResource(SSHMainBundle.class, "/org/jetbrains/git4idea/ssh/SSHMainBundle.properties");
myScriptPath = generator.generate();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -15,12 +15,12 @@
*/
package org.jetbrains.git4idea.ssh;
import com.intellij.openapi.util.io.FileUtilLight;
import com.intellij.util.ArrayUtil;
import com.trilead.ssh2.*;
import com.trilead.ssh2.crypto.PEMDecoder;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.util.rt.FileUtilRt;
import java.io.*;
import java.util.*;
@@ -302,7 +302,7 @@ public class SSHMain {
if (file.exists()) {
// if encrypted ask user for passphrase
String passphrase = null;
char[] text = FileUtilLight.loadFileText(file);
char[] text = FileUtilRt.loadFileText(file);
if (isEncryptedKey(text)) {
// need to ask passphrase from user
int i;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -17,11 +17,11 @@ package org.jetbrains.git4idea.util;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtilLight;
import com.intellij.util.PathUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.util.rt.FileUtilRt;
import java.io.File;
import java.io.FileWriter;
@@ -149,8 +149,8 @@ public class ScriptGenerator {
*/
@SuppressWarnings({"HardCodedStringLiteral"})
public File generate() throws IOException {
File scriptPath = myTempDir != null ? FileUtilLight.createTempFile(myTempDir, myPrefix, SCRIPT_EXT, true)
: FileUtilLight.createTempFile(myPrefix, SCRIPT_EXT);
File scriptPath = myTempDir != null ? FileUtilRt.createTempFile(myTempDir, myPrefix, SCRIPT_EXT, true)
: FileUtilRt.createTempFile(myPrefix, SCRIPT_EXT);
scriptPath.deleteOnExit();
PrintWriter out = new PrintWriter(new FileWriter(scriptPath));
try {
@@ -172,7 +172,7 @@ public class ScriptGenerator {
finally {
out.close();
}
FileUtilLight.setExecutableAttribute(scriptPath.getPath(), true);
FileUtilRt.setExecutableAttribute(scriptPath.getPath(), true);
return scriptPath;
}