mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
replaced String literal "UTF-8" with charset instance
This commit is contained in:
@@ -32,10 +32,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -274,7 +271,7 @@ public class GenerateAntBuildAction extends CompileActionBase {
|
||||
* @throws FileNotFoundException if file not found
|
||||
*/
|
||||
private static PrintWriter makeWriter(final File buildxmlFile) throws UnsupportedEncodingException, FileNotFoundException {
|
||||
return new PrintWriter(new OutputStreamWriter(new FileOutputStream(buildxmlFile), "UTF-8"));
|
||||
return new PrintWriter(new OutputStreamWriter(new FileOutputStream(buildxmlFile), CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
|
||||
private void ensureFilesWritable(Project project, File[] files) throws IOException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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,6 +23,7 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
@@ -104,7 +105,7 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate {
|
||||
ZipEntry entry;
|
||||
while ((entry = stream.getNextEntry()) != null) {
|
||||
if (condition.value(entry)) {
|
||||
return StreamUtil.readText(stream, TemplateModuleBuilder.UTF_8);
|
||||
return StreamUtil.readText(stream, CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.module.ModuleTypeManager;
|
||||
import com.intellij.openapi.util.ClearableLazyValue;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.platform.ProjectTemplate;
|
||||
import com.intellij.platform.ProjectTemplatesFactory;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -92,7 +93,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
|
||||
try {
|
||||
connection = getConnection(code + "_templates.xml");
|
||||
stream = connection.getInputStream();
|
||||
String text = StreamUtil.readText(stream, TemplateModuleBuilder.UTF_8);
|
||||
String text = StreamUtil.readText(stream, CharsetToolkit.UTF8_CHARSET);
|
||||
return createFromText(text);
|
||||
}
|
||||
catch (IOException ex) { // timeouts, lost connection etc
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -42,6 +42,7 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -177,7 +178,7 @@ public class SaveProjectAsTemplateAction extends AnAction {
|
||||
public InputStream getContent(final File file) throws IOException {
|
||||
if (virtualFile.getFileType().isBinary() || PROJECT_TEMPLATE_XML.equals(virtualFile.getName())) return STANDARD.getContent(file);
|
||||
String result = getEncodedContent(virtualFile, project, parameters);
|
||||
return new ByteArrayInputStream(result.getBytes(TemplateModuleBuilder.UTF_8));
|
||||
return new ByteArrayInputStream(result.getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -66,8 +66,6 @@ import java.util.zip.ZipInputStream;
|
||||
*/
|
||||
public class TemplateModuleBuilder extends ModuleBuilder {
|
||||
|
||||
public static final String UTF_8 = "UTF-8";
|
||||
|
||||
private final ModuleType myType;
|
||||
private List<WizardInputField> myAdditionalFields;
|
||||
private ArchivedProjectTemplate myTemplate;
|
||||
@@ -272,7 +270,8 @@ public class TemplateModuleBuilder extends ModuleBuilder {
|
||||
properties.put(ProjectTemplateParameterFactory.IJ_PROJECT_NAME, projectName);
|
||||
}
|
||||
String merged = FileTemplateUtil.mergeTemplate(properties, content, true);
|
||||
return StringUtilRt.convertLineSeparators(merged.replace("\\$", "$").replace("\\#", "#"), SystemInfo.isWindows ? "\r\n" : "\n").getBytes(UTF_8);
|
||||
return StringUtilRt.convertLineSeparators(merged.replace("\\$", "$").replace("\\#", "#"), SystemInfo.isWindows ? "\r\n" : "\n").getBytes(
|
||||
CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -98,7 +99,7 @@ public class TestClassesFilterTest {
|
||||
}
|
||||
|
||||
private static InputStreamReader getReader(String filterText) throws UnsupportedEncodingException {
|
||||
return new InputStreamReader(new ByteArrayInputStream(filterText.getBytes("UTF-8")));
|
||||
return new InputStreamReader(new ByteArrayInputStream(filterText.getBytes(CharsetToolkit.UTF8_CHARSET)));
|
||||
}
|
||||
|
||||
private static void checkForAllExcludedDefinedGroup(TestClassesFilter classesFilter) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -20,12 +20,12 @@ import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.projectRoots.impl.ProjectRootUtil;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
@@ -801,7 +801,7 @@ public class SrcRepositoryUseTest extends PsiTestCase{
|
||||
}
|
||||
|
||||
private static void rewriteFileExternally(VirtualFile vFile, String text) throws IOException {
|
||||
FileUtil.writeToFile(new File(vFile.getPath()), text.getBytes("UTF-8"));
|
||||
FileUtil.writeToFile(new File(vFile.getPath()), text.getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
vFile.refresh(false, false);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@ import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -58,7 +59,7 @@ public abstract class AbstractJavaFormatterTest extends LightIdeaTestCase {
|
||||
StringBuilder result = new StringBuilder(initial.length());
|
||||
List<byte[]> lines;
|
||||
try {
|
||||
LineReader reader = new LineReader(new ByteArrayInputStream(initial.getBytes("UTF-8")));
|
||||
LineReader reader = new LineReader(new ByteArrayInputStream(initial.getBytes(CharsetToolkit.UTF8_CHARSET)));
|
||||
lines = reader.readLines();
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
String contents = StringUtil.convertLineSeparators(FileUtil.loadFile(testFile, CharsetToolkit.UTF8));
|
||||
String contents = StringUtil.convertLineSeparators(FileUtil.loadFile(testFile, CharsetToolkit.UTF8_CHARSET));
|
||||
quickFixTestCase.configureFromFileText(testFile.getName(), contents);
|
||||
quickFixTestCase.bringRealEditorBack();
|
||||
final Pair<String, Boolean> pair = quickFixTestCase.parseActionHintImpl(quickFixTestCase.getFile(), contents);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.util.ThreadLocalCachedByteArray;
|
||||
import com.intellij.util.io.DataInputOutputUtil;
|
||||
import org.iq80.snappy.CorruptionException;
|
||||
import org.iq80.snappy.Snappy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -33,7 +34,7 @@ public class CompressionUtil {
|
||||
private static final int COMPRESSION_THRESHOLD = 64;
|
||||
private static final ThreadLocalCachedByteArray spareBufferLocal = new ThreadLocalCachedByteArray();
|
||||
|
||||
public static int writeCompressed(DataOutput out, byte[] bytes, int length) throws IOException {
|
||||
public static int writeCompressed(@NotNull DataOutput out, @NotNull byte[] bytes, int length) throws IOException {
|
||||
if (length > COMPRESSION_THRESHOLD) {
|
||||
final byte[] compressedOutputBuffer = spareBufferLocal.getBuffer(Snappy.maxCompressedLength(length));
|
||||
|
||||
@@ -41,20 +42,23 @@ public class CompressionUtil {
|
||||
DataInputOutputUtil.writeINT(out, -compressedSize);
|
||||
out.write(compressedOutputBuffer, 0, compressedSize);
|
||||
return compressedSize;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
DataInputOutputUtil.writeINT(out, length);
|
||||
out.write(bytes, 0, length);
|
||||
return length;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] readCompressed(DataInput in) throws IOException {
|
||||
@NotNull
|
||||
public static byte[] readCompressed(@NotNull DataInput in) throws IOException {
|
||||
int size = DataInputOutputUtil.readINT(in);
|
||||
if (size < 0) {
|
||||
byte[] bytes = spareBufferLocal.getBuffer(-size);
|
||||
in.readFully(bytes, 0, -size);
|
||||
return Snappy.uncompress(bytes, 0, -size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
byte[] bytes = new byte[size];
|
||||
in.readFully(bytes);
|
||||
return bytes;
|
||||
@@ -63,7 +67,8 @@ public class CompressionUtil {
|
||||
|
||||
private static final int STRING_COMPRESSION_THRESHOLD = 1024;
|
||||
|
||||
public static CharSequence uncompressCharSequence(Object string, Charset charset) {
|
||||
@NotNull
|
||||
public static CharSequence uncompressCharSequence(@NotNull Object string, @NotNull Charset charset) {
|
||||
if (string instanceof CharSequence) return (CharSequence)string;
|
||||
byte[] b = (byte[])string;
|
||||
try {
|
||||
@@ -71,12 +76,14 @@ public class CompressionUtil {
|
||||
byte[] bytes = spareBufferLocal.getBuffer(uncompressedLength);
|
||||
int bytesLength = Snappy.uncompress(b, 0, b.length, bytes, 0);
|
||||
return new String(bytes, 0, bytesLength, charset);
|
||||
} catch (CorruptionException ex) {
|
||||
}
|
||||
catch (CorruptionException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object compressCharSequence(CharSequence string, Charset charset) {
|
||||
@NotNull
|
||||
public static Object compressCharSequence(@NotNull CharSequence string, @NotNull Charset charset) {
|
||||
if (string.length() < STRING_COMPRESSION_THRESHOLD) {
|
||||
if (string instanceof CharBuffer && ((CharBuffer)string).capacity() > STRING_COMPRESSION_THRESHOLD) {
|
||||
string = string.toString(); // shrink to size
|
||||
@@ -85,7 +92,8 @@ public class CompressionUtil {
|
||||
}
|
||||
try {
|
||||
return Snappy.compress(string.toString().getBytes(charset));
|
||||
} catch (CorruptionException ex) {
|
||||
}
|
||||
catch (CorruptionException ex) {
|
||||
ex.printStackTrace();
|
||||
return string;
|
||||
}
|
||||
|
||||
+6
-7
@@ -38,10 +38,7 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.ByteSequence;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
|
||||
import com.intellij.testFramework.*;
|
||||
@@ -55,7 +52,9 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
@@ -490,10 +489,10 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase {
|
||||
@Override
|
||||
protected void run(@NotNull Result<VirtualFile> result) throws Throwable {
|
||||
if (advanceStamps) {
|
||||
file.setBinaryContent(content.getBytes("UTF-8"), -1, file.getTimeStamp() + 4000);
|
||||
file.setBinaryContent(content.getBytes(CharsetToolkit.UTF8_CHARSET), -1, file.getTimeStamp() + 4000);
|
||||
}
|
||||
else {
|
||||
file.setBinaryContent(content.getBytes("UTF-8"), file.getModificationStamp(), file.getTimeStamp());
|
||||
file.setBinaryContent(content.getBytes(CharsetToolkit.UTF8_CHARSET), file.getModificationStamp(), file.getTimeStamp());
|
||||
}
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -361,7 +361,7 @@ public abstract class AbstractExternalFilter {
|
||||
while (read != null && !startSection.matcher(StringUtil.toUpperCase(read)).find());
|
||||
|
||||
if (input instanceof MyReader && contentEncoding != null) {
|
||||
if (!contentEncoding.equalsIgnoreCase("UTF-8") &&
|
||||
if (!contentEncoding.equalsIgnoreCase(CharsetToolkit.UTF8) &&
|
||||
!contentEncoding.equals(((MyReader)input).getEncoding()))
|
||||
{ //restart page parsing with correct encoding
|
||||
Reader stream;
|
||||
|
||||
+3
-2
@@ -54,6 +54,7 @@ import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
@@ -185,7 +186,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
|
||||
new File(outputPath).mkdirs();
|
||||
final File file = new File(outputPath, toolName + ext);
|
||||
inspectionsResults.add(file);
|
||||
FileUtil.writeToFile(file, ("</" + InspectionsBundle.message("inspection.problems") + ">").getBytes("UTF-8"), true);
|
||||
FileUtil.writeToFile(file, ("</" + InspectionsBundle.message("inspection.problems") + ">").getBytes(CharsetToolkit.UTF8_CHARSET), true);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
@@ -221,7 +222,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
|
||||
final File file = new File(outputPath, toolName + ext);
|
||||
inspectionsResults.add(file);
|
||||
|
||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
|
||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), CharsetToolkit.UTF8_CHARSET);
|
||||
try {
|
||||
JDOMUtil.writeDocument(doc, writer, "\n");
|
||||
}
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManagerImpl;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -287,7 +288,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
pathMacroManager.collapsePaths(element);
|
||||
JDOMUtil.writeElement(element, writer, "\n");
|
||||
}
|
||||
printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName, true), "UTF-8")));
|
||||
printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName, true), CharsetToolkit.UTF8_CHARSET)));
|
||||
printWriter.append("\n");
|
||||
printWriter.append(writer.toString());
|
||||
}
|
||||
|
||||
@@ -15,13 +15,10 @@
|
||||
*/
|
||||
package com.intellij.ide.fileTemplates.impl;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -247,7 +244,7 @@ class FTManager {
|
||||
else {
|
||||
// both customized content on disk and corresponding template are present
|
||||
try {
|
||||
final String diskText = StringUtil.convertLineSeparators(FileUtil.loadFile(customizedTemplateFile, CONTENT_ENCODING));
|
||||
final String diskText = StringUtil.convertLineSeparators(FileUtil.loadFile(customizedTemplateFile, CharsetToolkit.UTF8_CHARSET));
|
||||
final String templateText = templateToSave.getText();
|
||||
if (!diskText.equals(templateText)) {
|
||||
// save only if texts differ to avoid unnecessary file touching
|
||||
@@ -278,16 +275,7 @@ class FTManager {
|
||||
FileUtil.delete(templateFile);
|
||||
fileOutputStream = new FileOutputStream(templateFile);
|
||||
}
|
||||
OutputStreamWriter outputStreamWriter;
|
||||
try{
|
||||
outputStreamWriter = new OutputStreamWriter(fileOutputStream, CONTENT_ENCODING);
|
||||
}
|
||||
catch (UnsupportedEncodingException e){
|
||||
Messages.showMessageDialog(IdeBundle.message("error.unable.to.save.file.template.using.encoding", template.getName(),
|
||||
CONTENT_ENCODING),
|
||||
CommonBundle.getErrorTitle(), Messages.getErrorIcon());
|
||||
outputStreamWriter = new OutputStreamWriter(fileOutputStream);
|
||||
}
|
||||
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, CharsetToolkit.UTF8_CHARSET);
|
||||
String content = template.getText();
|
||||
|
||||
if (!lineSeparator.equals("\n")){
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.extensions.PluginDescriptor;
|
||||
import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -235,7 +236,7 @@ public class FileTemplatesLoader {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final String text = FileUtil.loadFile(file, FTManager.CONTENT_ENCODING);
|
||||
final String text = FileUtil.loadFile(file, CharsetToolkit.UTF8_CHARSET);
|
||||
manager.addTemplate(templateQName, extension).setText(text);
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
+4
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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 com.intellij.ide.passwordSafe.impl.providers;
|
||||
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
@@ -224,12 +224,7 @@ public class EncryptionUtil {
|
||||
if (len < 0 || len > plain.length - 4) {
|
||||
throw new IllegalStateException("Unmatched password is used");
|
||||
}
|
||||
try {
|
||||
return new String(plain, 4, len, "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalStateException("UTF-8 is not available", e);
|
||||
}
|
||||
return new String(plain, 4, len, CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,12 +234,7 @@ public class EncryptionUtil {
|
||||
* @return the UTF-8 encoded string
|
||||
*/
|
||||
public static byte[] getUTF8Bytes(String string) {
|
||||
try {
|
||||
return string.getBytes("UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalStateException("UTF-8 encoding is not available", e);
|
||||
}
|
||||
return string.getBytes(CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-7
@@ -31,13 +31,13 @@ import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -338,12 +338,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
|
||||
private static String decryptPassword(byte[] pw) throws MasterPasswordUnavailableException {
|
||||
if (!SystemInfo.isWindows) throw new AssertionError("Windows OS expected");
|
||||
|
||||
try {
|
||||
return new String(WindowsCryptUtils.unprotect(pw), "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalStateException("UTF-8 not available", e);
|
||||
}
|
||||
return new String(WindowsCryptUtils.unprotect(pw), CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
|
||||
public boolean isPasswordEncrypted() {
|
||||
|
||||
+2
-1
@@ -56,6 +56,7 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.psi.PsiLock;
|
||||
@@ -519,7 +520,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
private static void createLocatorFile() {
|
||||
File locatorFile = new File(PathManager.getSystemPath() + "/" + ApplicationEx.LOCATOR_FILE_NAME);
|
||||
try {
|
||||
byte[] data = PathManager.getHomePath().getBytes("UTF-8");
|
||||
byte[] data = PathManager.getHomePath().getBytes(CharsetToolkit.UTF8_CHARSET);
|
||||
FileUtil.writeToFile(locatorFile, data);
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -281,7 +281,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
final VirtualFile nameFile = ideaDir.findChild(ProjectImpl.NAME_FILE);
|
||||
if (nameFile != null && nameFile.isValid()) {
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(nameFile.getInputStream(), "UTF-8"));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(nameFile.getInputStream(), CharsetToolkit.UTF8_CHARSET));
|
||||
try {
|
||||
final String name = in.readLine();
|
||||
if (name != null && name.length() > 0) {
|
||||
|
||||
+6
-3
@@ -36,9 +36,12 @@ import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.StandardFileSystems;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.HttpRequests;
|
||||
import com.intellij.util.io.UrlConnectionUtil;
|
||||
@@ -648,11 +651,11 @@ public final class UpdateChecker {
|
||||
args.append('&');
|
||||
}
|
||||
|
||||
args.append(URLEncoder.encode(name, "UTF-8"));
|
||||
args.append(URLEncoder.encode(name, CharsetToolkit.UTF8));
|
||||
|
||||
String value = ourAdditionalRequestOptions.get(name);
|
||||
if (!StringUtil.isEmpty(value)) {
|
||||
args.append('=').append(URLEncoder.encode(value, "UTF-8"));
|
||||
args.append('=').append(URLEncoder.encode(value, CharsetToolkit.UTF8));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -150,7 +151,7 @@ public class X11UiUtil {
|
||||
@Nullable
|
||||
private String getUtfStringProperty(long window, long name) throws Exception {
|
||||
byte[] bytes = getWindowProperty(window, name, UTF8_STRING, FORMAT_BYTE);
|
||||
return bytes != null ? new String(bytes, "UTF-8") : null;
|
||||
return bytes != null ? new String(bytes, CharsetToolkit.UTF8_CHARSET) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -115,7 +115,7 @@ public abstract class IntegrationTestCase extends PlatformTestCase {
|
||||
}
|
||||
|
||||
protected void setContent(VirtualFile f, String content, long timestamp) throws IOException {
|
||||
f.setBinaryContent(content.getBytes("UTF-8"), -1, timestamp);
|
||||
f.setBinaryContent(content.getBytes(CharsetToolkit.UTF8_CHARSET), -1, timestamp);
|
||||
}
|
||||
|
||||
protected String createFileExternally(String name) throws IOException {
|
||||
@@ -126,7 +126,7 @@ public abstract class IntegrationTestCase extends PlatformTestCase {
|
||||
File f = new File(myRoot.getPath(), name);
|
||||
assertTrue(f.getPath(), f.getParentFile().mkdirs() || f.getParentFile().isDirectory());
|
||||
assertTrue(f.getPath(), f.createNewFile() || f.exists());
|
||||
if (content != null) FileUtil.writeToFile(f, content.getBytes("UTF-8"));
|
||||
if (content != null) FileUtil.writeToFile(f, content.getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
return FileUtil.toSystemIndependentName(f.getPath());
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public abstract class IntegrationTestCase extends PlatformTestCase {
|
||||
|
||||
protected void setContentExternally(String path, String content) throws IOException {
|
||||
File f = new File(path);
|
||||
FileUtil.writeToFile(f, content.getBytes("UTF-8"));
|
||||
FileUtil.writeToFile(f, content.getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
assertTrue(f.getPath(), f.setLastModified(f.lastModified() + 2000));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.testFramework.PlatformLangTestCase;
|
||||
|
||||
import java.io.File;
|
||||
@@ -29,7 +30,7 @@ public class LocatorTest extends PlatformLangTestCase {
|
||||
assertTrue("doesn't exist: " + locatorFile.getPath(), locatorFile.exists());
|
||||
assertTrue("can't read: " + locatorFile.getPath(), locatorFile.canRead());
|
||||
|
||||
String home = FileUtil.loadFile(locatorFile, "UTF-8");
|
||||
String home = FileUtil.loadFile(locatorFile, CharsetToolkit.UTF8_CHARSET);
|
||||
assertTrue(home, StringUtil.isNotEmpty(home));
|
||||
|
||||
assertEquals(home, PathManager.getHomePath());
|
||||
|
||||
+6
-6
@@ -150,7 +150,7 @@ public class FileDocumentManagerImplTest extends PlatformLangTestCase {
|
||||
final Document[] unsavedDocuments = myDocumentManager.getUnsavedDocuments();
|
||||
assertEquals(1, unsavedDocuments.length);
|
||||
assertSame(document, unsavedDocuments[0]);
|
||||
assertEquals("test", new String(file.contentsToByteArray(), "UTF-8"));
|
||||
assertEquals("test", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
|
||||
public void testGetUnsavedDocuments_afterSaveAllDocuments() throws Exception {
|
||||
@@ -218,7 +218,7 @@ public class FileDocumentManagerImplTest extends PlatformLangTestCase {
|
||||
final Document[] unsavedDocuments = myDocumentManager.getUnsavedDocuments();
|
||||
assertEquals(1, unsavedDocuments.length);
|
||||
assertSame(document, unsavedDocuments[0]);
|
||||
assertEquals("test", new String(file.contentsToByteArray(), "UTF-8"));
|
||||
assertEquals("test", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
finally {
|
||||
myDocumentManager.dropAllUnsavedDocuments();
|
||||
@@ -296,7 +296,7 @@ public class FileDocumentManagerImplTest extends PlatformLangTestCase {
|
||||
myDocumentManager.saveDocument(document);
|
||||
assertTrue(stamp != file.getModificationStamp());
|
||||
assertEquals(document.getModificationStamp(), file.getModificationStamp());
|
||||
assertEquals("xxx test", new String(file.contentsToByteArray(), "UTF-8"));
|
||||
assertEquals("xxx test", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
|
||||
public void testSaveAllDocuments_DocumentWasChanged() throws Exception {
|
||||
@@ -313,7 +313,7 @@ public class FileDocumentManagerImplTest extends PlatformLangTestCase {
|
||||
|
||||
myDocumentManager.saveAllDocuments();
|
||||
assertNotEquals(stamp, file.getModificationStamp());
|
||||
assertEquals("xxx test", new String(file.contentsToByteArray(), "UTF-8"));
|
||||
assertEquals("xxx test", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
|
||||
public void testGetFile() throws Exception {
|
||||
@@ -342,7 +342,7 @@ public class FileDocumentManagerImplTest extends PlatformLangTestCase {
|
||||
});
|
||||
|
||||
myDocumentManager.saveAllDocuments();
|
||||
assertEquals("xxx test\rtest", new String(file.contentsToByteArray(), "UTF-8"));
|
||||
assertEquals("xxx test\rtest", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
|
||||
public void testContentChanged_noDocument() throws Exception {
|
||||
@@ -532,7 +532,7 @@ public class FileDocumentManagerImplTest extends PlatformLangTestCase {
|
||||
|
||||
assertEquals("old test", document.getText());
|
||||
assertEquals(file.getModificationStamp(), document.getModificationStamp());
|
||||
assertEquals("old test", new String(file.contentsToByteArray(), "UTF-8"));
|
||||
assertEquals("old test", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
|
||||
assertEquals(documentStamp, document.getModificationStamp());
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ public class VfsUtilTest extends PlatformLangTestCase {
|
||||
|
||||
private static void doAsyncRefreshTest(File temp) throws Exception {
|
||||
final int N = 1000;
|
||||
final byte[] data = "xxx".getBytes("UTF-8");
|
||||
final byte[] data = "xxx".getBytes(CharsetToolkit.UTF8_CHARSET);
|
||||
|
||||
LocalFileSystem fs = LocalFileSystem.getInstance();
|
||||
VirtualFile vTemp = fs.findFileByIoFile(temp);
|
||||
|
||||
+1
-1
@@ -284,7 +284,7 @@ public class LocalFileSystemTest extends PlatformLangTestCase {
|
||||
|
||||
final VirtualFile file = myFS.refreshAndFindFileByIoFile(targetFile);
|
||||
assertNotNull(file);
|
||||
file.setBinaryContent("hello".getBytes("UTF-8"), 0, 0, requestor);
|
||||
file.setBinaryContent("hello".getBytes(CharsetToolkit.UTF8_CHARSET), 0, 0, requestor);
|
||||
assertTrue(file.getLength() > 0);
|
||||
|
||||
final VirtualFile check = myFS.refreshAndFindFileByIoFile(hardLinkFile);
|
||||
|
||||
+4
-2
@@ -20,7 +20,9 @@ import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.injected.editor.DocumentWindow;
|
||||
import com.intellij.injected.editor.EditorWindow;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
@@ -291,7 +293,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
|
||||
assertTrue(getMessage("Cannot find file " + fullPath, message), ioFile.exists());
|
||||
String fileText = null;
|
||||
try {
|
||||
fileText = FileUtil.loadFile(ioFile, CharsetToolkit.UTF8);
|
||||
fileText = FileUtil.loadFile(ioFile, CharsetToolkit.UTF8_CHARSET);
|
||||
} catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ public abstract class UsefulTestCase extends TestCase {
|
||||
VfsTestUtil.overwriteTestData(filePath, actualText);
|
||||
System.out.println("File " + filePath + " created.");
|
||||
}
|
||||
fileText = FileUtil.loadFile(new File(filePath), CharsetToolkit.UTF8);
|
||||
fileText = FileUtil.loadFile(new File(filePath), CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
VfsTestUtil.overwriteTestData(filePath, actualText);
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -381,7 +382,7 @@ public class FileUtilRt {
|
||||
|
||||
@NotNull
|
||||
public static char[] loadFileText(@NotNull File file) throws IOException {
|
||||
return loadFileText(file, null);
|
||||
return loadFileText(file, (String)null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -396,6 +397,16 @@ public class FileUtilRt {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
@NotNull
|
||||
public static char[] loadFileText(@NotNull File file, @NotNull @NonNls Charset encoding) throws IOException {
|
||||
Reader reader = new InputStreamReader(new FileInputStream(file), encoding);
|
||||
try {
|
||||
return loadText(reader, (int)file.length());
|
||||
}
|
||||
finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static char[] loadText(@NotNull Reader reader, int length) throws IOException {
|
||||
|
||||
@@ -15,13 +15,11 @@
|
||||
*/
|
||||
package com.intellij.openapi.diagnostic;
|
||||
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.Base64Converter;
|
||||
import com.intellij.util.PathUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class Attachment {
|
||||
public static final Attachment[] EMPTY_ARRAY = new Attachment[0];
|
||||
private final String myPath;
|
||||
@@ -43,12 +41,7 @@ public class Attachment {
|
||||
|
||||
@NotNull
|
||||
public static byte[] getBytes(@NotNull String content) {
|
||||
try {
|
||||
return content.getBytes("UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException ignored) {
|
||||
return ArrayUtil.EMPTY_BYTE_ARRAY;
|
||||
}
|
||||
return content.getBytes(CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.CommonBundle;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.concurrency.FixedFuture;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -32,6 +33,7 @@ import org.jetbrains.annotations.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
@@ -1116,7 +1118,7 @@ public class FileUtil extends FileUtilRt {
|
||||
}
|
||||
|
||||
public static void appendToFile(@NotNull File file, @NotNull String text) throws IOException {
|
||||
writeToFile(file, text.getBytes("UTF-8"), true);
|
||||
writeToFile(file, text.getBytes(CharsetToolkit.UTF8_CHARSET), true);
|
||||
}
|
||||
|
||||
public static void writeToFile(@NotNull File file, @NotNull byte[] text) throws IOException {
|
||||
@@ -1124,7 +1126,7 @@ public class FileUtil extends FileUtilRt {
|
||||
}
|
||||
|
||||
public static void writeToFile(@NotNull File file, @NotNull String text) throws IOException {
|
||||
writeToFile(file, text.getBytes("UTF-8"), false);
|
||||
writeToFile(file, text.getBytes(CharsetToolkit.UTF8_CHARSET), false);
|
||||
}
|
||||
|
||||
public static void writeToFile(@NotNull File file, @NotNull byte[] text, int off, int len) throws IOException {
|
||||
@@ -1421,6 +1423,10 @@ public class FileUtil extends FileUtilRt {
|
||||
public static String loadFile(@NotNull File file, @Nullable @NonNls String encoding) throws IOException {
|
||||
return FileUtilRt.loadFile(file, encoding);
|
||||
}
|
||||
@NotNull
|
||||
public static String loadFile(@NotNull File file, @NotNull @NonNls Charset encoding) throws IOException {
|
||||
return String.valueOf(FileUtilRt.loadFileText(file, encoding));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String loadFile(@NotNull File file, @Nullable @NonNls String encoding, boolean convertLineSeparators) throws IOException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -18,9 +18,11 @@ package com.intellij.openapi.util.io;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.io.UnsyncByteArrayOutputStream;
|
||||
import com.intellij.util.text.StringFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class StreamUtil {
|
||||
private StreamUtil() {
|
||||
@@ -64,7 +66,11 @@ public class StreamUtil {
|
||||
return new String(data);
|
||||
}
|
||||
|
||||
public static String readText(InputStream inputStream, String encoding) throws IOException {
|
||||
public static String readText(InputStream inputStream, @NotNull String encoding) throws IOException {
|
||||
final byte[] data = loadFromStream(inputStream);
|
||||
return new String(data, encoding);
|
||||
}
|
||||
public static String readText(InputStream inputStream, @NotNull Charset encoding) throws IOException {
|
||||
final byte[] data = loadFromStream(inputStream);
|
||||
return new String(data, encoding);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.util;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.io.URLUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -33,7 +34,6 @@ import java.util.Locale;
|
||||
* @author max
|
||||
*/
|
||||
public class ResourceUtil {
|
||||
@NonNls private static final String ENCODING_UTF_8 = "UTF-8";
|
||||
|
||||
private ResourceUtil() {
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class ResourceUtil {
|
||||
public static String loadText(@NotNull URL url) throws IOException {
|
||||
InputStream inputStream = new BufferedInputStream(URLUtil.openStream(url));
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(inputStream, ENCODING_UTF_8);
|
||||
InputStreamReader reader = new InputStreamReader(inputStream, CharsetToolkit.UTF8_CHARSET);
|
||||
try {
|
||||
StringBuilder text = new StringBuilder();
|
||||
char[] buf = new char[5000];
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.intellij.util.io;
|
||||
|
||||
import com.intellij.openapi.Forceable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.*;
|
||||
@@ -138,27 +139,16 @@ public class RandomAccessDataFile implements Forceable, Closeable {
|
||||
}
|
||||
|
||||
public String getUTF(long addr) {
|
||||
try {
|
||||
int len = getInt(addr);
|
||||
byte[] bytes = new byte[len];
|
||||
get(addr + 4, bytes, 0, len);
|
||||
return new String(bytes, "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
// Can't be
|
||||
return "";
|
||||
}
|
||||
int len = getInt(addr);
|
||||
byte[] bytes = new byte[len];
|
||||
get(addr + 4, bytes, 0, len);
|
||||
return new String(bytes, CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
|
||||
public void putUTF(long addr, String value) {
|
||||
try {
|
||||
final byte[] bytes = value.getBytes("UTF-8");
|
||||
putInt(addr, bytes.length);
|
||||
put(addr + 4, bytes, 0, bytes.length);
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
// Can't be
|
||||
}
|
||||
final byte[] bytes = value.getBytes(CharsetToolkit.UTF8_CHARSET);
|
||||
putInt(addr, bytes.length);
|
||||
put(addr + 4, bytes, 0, bytes.length);
|
||||
}
|
||||
|
||||
public long length() {
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
@@ -169,7 +168,7 @@ public class URLUtil {
|
||||
for (int j = 0; j < bytes.size(); j++) {
|
||||
bytesArray[j] = (byte)bytes.getQuick(j);
|
||||
}
|
||||
decoded.append(new String(bytesArray, Charset.forName("UTF-8")));
|
||||
decoded.append(new String(bytesArray, CharsetToolkit.UTF8_CHARSET));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.win32.FileInfo;
|
||||
import com.intellij.openapi.util.io.win32.IdeaWin32;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.TimeoutUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -355,7 +356,7 @@ public class FileAttributesReadingTest {
|
||||
assertTrue(getAttributes(dir).isDirectory());
|
||||
|
||||
file = new File(dir, "file.txt");
|
||||
FileUtil.writeToFile(file, "test".getBytes("UTF-8"));
|
||||
FileUtil.writeToFile(file, "test".getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
assertTrue(file.exists());
|
||||
assertFileAttributes(file);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.util.io;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.Processor;
|
||||
@@ -228,7 +229,7 @@ public class IoTestUtil {
|
||||
try {
|
||||
for (int i = 0; i < data.length; i += 2) {
|
||||
stream.putNextEntry(new ZipEntry(data[i]));
|
||||
stream.write(data[i + 1].getBytes("UTF-8"));
|
||||
stream.write(data[i + 1].getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
stream.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.coverage;
|
||||
|
||||
import com.intellij.execution.configurations.SimpleJavaParameters;
|
||||
@@ -5,6 +20,7 @@ import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -67,7 +83,7 @@ public abstract class JavaCoverageRunner extends CoverageRunner {
|
||||
}
|
||||
|
||||
protected static void write2file(File tempFile, String arg) throws IOException {
|
||||
FileUtil.writeToFile(tempFile, (arg + "\n").getBytes("UTF-8"), true);
|
||||
FileUtil.writeToFile(tempFile, (arg + "\n").getBytes(CharsetToolkit.UTF8_CHARSET), true);
|
||||
}
|
||||
|
||||
protected static File createTempFile() throws IOException {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
@@ -30,9 +31,9 @@ public class EncodingManager extends FileDocumentManagerAdapter {
|
||||
static {
|
||||
Map<String, Charset> map = new HashMap<String, Charset>();
|
||||
map.put("latin1", Charset.forName("ISO-8859-1"));
|
||||
map.put("utf-8", Charset.forName("UTF-8"));
|
||||
map.put("utf-16be", Charset.forName("UTF-16BE"));
|
||||
map.put("utf-16le", Charset.forName("UTF-16LE"));
|
||||
map.put("utf-8", CharsetToolkit.UTF8_CHARSET);
|
||||
map.put("utf-16be", CharsetToolkit.UTF_16BE_CHARSET);
|
||||
map.put("utf-16le", CharsetToolkit.UTF_16LE_CHARSET);
|
||||
encodingMap = Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@ package org.jetbrains.generate.tostring.template;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.jetbrains.generate.tostring.exception.TemplateResourceException;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
@@ -70,6 +71,6 @@ public class TemplateResourceLocator {
|
||||
*/
|
||||
private static String readFile(String resource) throws IOException {
|
||||
BufferedInputStream in = new BufferedInputStream(TemplateResourceLocator.class.getResourceAsStream(resource));
|
||||
return StringUtil.convertLineSeparators(FileUtil.loadTextAndClose(new InputStreamReader(in, "UTF-8")));
|
||||
return StringUtil.convertLineSeparators(FileUtil.loadTextAndClose(new InputStreamReader(in, CharsetToolkit.UTF8_CHARSET)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -63,7 +63,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -87,14 +86,6 @@ public class GitUtil {
|
||||
return o1.getPresentableUrl().compareTo(o2.getPresentableUrl());
|
||||
}
|
||||
};
|
||||
/**
|
||||
* The UTF-8 encoding name
|
||||
*/
|
||||
public static final String UTF8_ENCODING = "UTF-8";
|
||||
/**
|
||||
* The UTF8 charset
|
||||
*/
|
||||
public static final Charset UTF8_CHARSET = Charset.forName(UTF8_ENCODING);
|
||||
public static final String DOT_GIT = ".git";
|
||||
|
||||
public static final String ORIGIN_HEAD = "origin/HEAD";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -436,7 +437,7 @@ public class GitBranchUtil {
|
||||
// the case after git init and before first commit - there is no branch and no output, and we'll take refs/heads/master
|
||||
String head;
|
||||
try {
|
||||
head = FileUtil.loadFile(new File(root.getPath(), GitRepositoryFiles.GIT_HEAD), GitUtil.UTF8_ENCODING).trim();
|
||||
head = FileUtil.loadFile(new File(root.getPath(), GitRepositoryFiles.GIT_HEAD), CharsetToolkit.UTF8_CHARSET).trim();
|
||||
final String prefix = "ref: refs/heads/";
|
||||
return head.startsWith(prefix) ?
|
||||
Collections.singletonList(head.substring(prefix.length())) :
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -20,7 +20,6 @@ import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.GitVcs;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -126,7 +125,6 @@ public class GitBinaryHandler extends GitHandler {
|
||||
public void processTerminated(int exitCode) {
|
||||
if (exitCode != 0 && !isIgnoredErrorCode(exitCode)) {
|
||||
Charset cs = getCharset();
|
||||
cs = cs == null ? GitUtil.UTF8_CHARSET : cs;
|
||||
String message = new String(myStderr.toByteArray(), cs);
|
||||
if (message.length() == 0) {
|
||||
//noinspection ThrowableResultOfMethodCallIgnored
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.ProcessEventListener;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -87,7 +88,8 @@ public abstract class GitHandler {
|
||||
|
||||
@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"})
|
||||
@NonNls
|
||||
private Charset myCharset = Charset.forName("UTF-8"); // Character set to use for IO
|
||||
@NotNull
|
||||
private Charset myCharset = CharsetToolkit.UTF8_CHARSET; // Character set to use for IO
|
||||
|
||||
private final EventDispatcher<ProcessEventListener> myListeners = EventDispatcher.create(ProcessEventListener.class);
|
||||
@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"})
|
||||
@@ -622,6 +624,7 @@ public abstract class GitHandler {
|
||||
/**
|
||||
* @return a character set to use for IO
|
||||
*/
|
||||
@NotNull
|
||||
public Charset getCharset() {
|
||||
return myCharset;
|
||||
}
|
||||
@@ -632,7 +635,7 @@ public abstract class GitHandler {
|
||||
* @param charset a character set
|
||||
*/
|
||||
@SuppressWarnings({"SameParameterValue"})
|
||||
public void setCharset(final Charset charset) {
|
||||
public void setCharset(@NotNull Charset charset) {
|
||||
myCharset = charset;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -127,17 +127,18 @@ public abstract class GitTextHandler extends GitHandler {
|
||||
}
|
||||
|
||||
private static class MyOSProcessHandler extends OSProcessHandler {
|
||||
@NotNull
|
||||
private final Charset myCharset;
|
||||
|
||||
public MyOSProcessHandler(Process process, GeneralCommandLine commandLine, Charset charset) {
|
||||
public MyOSProcessHandler(Process process, GeneralCommandLine commandLine, @NotNull Charset charset) {
|
||||
super(process, commandLine.getCommandLineString());
|
||||
myCharset = charset;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Charset getCharset() {
|
||||
Charset charset = myCharset;
|
||||
return charset == null ? super.getCharset() : charset;
|
||||
return myCharset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.commands.GitCommand;
|
||||
import git4idea.commands.GitSimpleHandler;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -177,7 +177,7 @@ public class GitConfigUtil {
|
||||
// ignore exception
|
||||
}
|
||||
if (encoding == null || encoding.length() == 0) {
|
||||
encoding = GitUtil.UTF8_ENCODING;
|
||||
encoding = CharsetToolkit.UTF8;
|
||||
}
|
||||
return encoding;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.VcsKey;
|
||||
import com.intellij.openapi.vcs.update.FileGroup;
|
||||
import com.intellij.openapi.vcs.update.UpdatedFiles;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitRevisionNumber;
|
||||
import git4idea.GitUtil;
|
||||
@@ -122,7 +123,7 @@ public class MergeChangeCollector {
|
||||
File mergeHeadsFile = new File(root, GitRepositoryFiles.GIT_MERGE_HEAD);
|
||||
try {
|
||||
if (mergeHeadsFile.exists()) {
|
||||
String mergeHeads = new String(FileUtil.loadFileText(mergeHeadsFile, GitUtil.UTF8_ENCODING));
|
||||
String mergeHeads = new String(FileUtil.loadFileText(mergeHeadsFile, CharsetToolkit.UTF8));
|
||||
for (StringScanner s = new StringScanner(mergeHeads); s.hasMoreData();) {
|
||||
String head = s.line();
|
||||
if (head.length() == 0) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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,6 +17,7 @@ package git4idea.rebase;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitRevisionNumber;
|
||||
@@ -93,7 +94,7 @@ public class GitRebaseUtils {
|
||||
File nextFile = new File(rebaseDir, "next");
|
||||
int next;
|
||||
try {
|
||||
next = Integer.parseInt(FileUtil.loadFile(nextFile, GitUtil.UTF8_ENCODING).trim());
|
||||
next = Integer.parseInt(FileUtil.loadFile(nextFile, CharsetToolkit.UTF8_CHARSET).trim());
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
@@ -105,7 +106,7 @@ public class GitRebaseUtils {
|
||||
String hash = null;
|
||||
String subject = null;
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(commitFile), GitUtil.UTF8_CHARSET));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(commitFile), CharsetToolkit.UTF8_CHARSET));
|
||||
try {
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitPlatformFacade;
|
||||
import git4idea.GitUtil;
|
||||
@@ -430,7 +431,7 @@ public class GitRebaser {
|
||||
}
|
||||
try {
|
||||
TreeMap<String, String> pickLines = new TreeMap<String, String>();
|
||||
StringScanner s = new StringScanner(new String(FileUtil.loadFileText(new File(path), GitUtil.UTF8_ENCODING)));
|
||||
StringScanner s = new StringScanner(new String(FileUtil.loadFileText(new File(path), CharsetToolkit.UTF8)));
|
||||
while (s.hasMoreData()) {
|
||||
if (!s.tryConsume("pick ")) {
|
||||
s.line();
|
||||
@@ -439,7 +440,7 @@ public class GitRebaser {
|
||||
String commit = s.spaceToken();
|
||||
pickLines.put(commit, "pick " + commit + " " + s.line());
|
||||
}
|
||||
PrintWriter w = new PrintWriter(new OutputStreamWriter(new FileOutputStream(path), GitUtil.UTF8_ENCODING));
|
||||
PrintWriter w = new PrintWriter(new OutputStreamWriter(new FileOutputStream(path), CharsetToolkit.UTF8));
|
||||
try {
|
||||
for (String commit : myCommits) {
|
||||
String key = pickLines.headMap(commit + "\u0000").lastKey();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -52,7 +52,7 @@ public class GitStashUtils {
|
||||
loadStashStack(project, root, Charset.forName(GitConfigUtil.getLogEncoding(project, root)), consumer);
|
||||
}
|
||||
|
||||
public static void loadStashStack(@NotNull Project project, @NotNull VirtualFile root, final Charset charset,
|
||||
public static void loadStashStack(@NotNull Project project, @NotNull VirtualFile root, @NotNull Charset charset,
|
||||
final Consumer<StashInfo> consumer) {
|
||||
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.STASH.readLockingCommand());
|
||||
h.setSilent(true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.VcsNotifier;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
@@ -106,7 +107,7 @@ public class GitTagDialog extends DialogWrapper {
|
||||
/**
|
||||
* Encoding for the message file
|
||||
*/
|
||||
@NonNls private static final String MESSAGE_FILE_ENCODING = "UTF-8";
|
||||
@NonNls private static final String MESSAGE_FILE_ENCODING = CharsetToolkit.UTF8;
|
||||
|
||||
/**
|
||||
* A constructor
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.plugins.github.api;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HeaderElement;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
@@ -469,7 +485,7 @@ public class GithubApiUtil {
|
||||
boolean withClosed) throws IOException {
|
||||
try {
|
||||
String state = withClosed ? "" : " state:open";
|
||||
query = URLEncoder.encode("repo:" + user + "/" + repo + " " + query + state, "UTF-8");
|
||||
query = URLEncoder.encode("repo:" + user + "/" + repo + " " + query + state, CharsetToolkit.UTF8);
|
||||
String path = "/search/issues?q=" + query;
|
||||
|
||||
//TODO: Use bodyHtml for issues - GitHub does not support this feature for SearchApi yet
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.plugins.github.api;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -5,7 +20,7 @@ import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.net.HttpConfigurable;
|
||||
import com.intellij.util.net.ssl.CertificateManager;
|
||||
import org.apache.http.*;
|
||||
@@ -361,7 +376,7 @@ public class GithubConnection {
|
||||
|
||||
@NotNull
|
||||
private static JsonElement parseResponse(@NotNull InputStream githubResponse) throws IOException {
|
||||
Reader reader = new InputStreamReader(githubResponse, "UTF-8");
|
||||
Reader reader = new InputStreamReader(githubResponse, CharsetToolkit.UTF8_CHARSET);
|
||||
try {
|
||||
return new JsonParser().parse(reader);
|
||||
}
|
||||
|
||||
+1
-1
@@ -234,7 +234,7 @@ public class ManifestGenerationTest extends MavenCompilingTestCase {
|
||||
VfsTestUtil.overwriteTestData(filePath, actualText);
|
||||
System.out.println("File " + filePath + " created.");
|
||||
}
|
||||
fileText = FileUtil.loadFile(new File(filePath), CharsetToolkit.UTF8);
|
||||
fileText = FileUtil.loadFile(new File(filePath), CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
VfsTestUtil.overwriteTestData(filePath, actualText);
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.popup.util.PopupUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.jetbrains.idea.svn.NativeLogReader;
|
||||
import org.jetbrains.idea.svn.SSLExceptionsHelper;
|
||||
import org.jetbrains.idea.svn.SvnNativeLogParser;
|
||||
@@ -29,7 +30,6 @@ import org.tmatesoft.svn.util.SVNLogType;
|
||||
|
||||
import javax.net.ssl.SSLHandshakeException;
|
||||
import javax.net.ssl.SSLProtocolException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
@@ -121,12 +121,7 @@ public class SvnKitDebugLogger extends SVNDebugLogAdapter {
|
||||
public void log(final SVNLogType logType, final String message, final byte[] data) {
|
||||
if (shouldLog(logType)) {
|
||||
if (data != null) {
|
||||
try {
|
||||
myLog.info(message + "\n" + new String(data, "UTF-8"));
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
myLog.info(message + "\n" + new String(data));
|
||||
}
|
||||
myLog.info(message + "\n" + new String(data, CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
else {
|
||||
myLog.info(message);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.tasks.Task;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -134,7 +135,7 @@ public class WorkingContextManager {
|
||||
Element element = new Element("context");
|
||||
saveContext(element);
|
||||
String s = new XMLOutputter().outputString(element);
|
||||
entry.setData(s.getBytes("UTF-8"));
|
||||
entry.setData(s.getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
|
||||
@@ -1,9 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.tasks.generic;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.tasks.Task;
|
||||
import com.intellij.tasks.TaskRepositorySubtype;
|
||||
import com.intellij.tasks.TaskRepositoryType;
|
||||
@@ -211,7 +227,7 @@ public class GenericRepository extends BaseRepositoryImpl {
|
||||
}
|
||||
else {
|
||||
InputStream stream = method.getResponseBodyAsStream();
|
||||
responseBody = stream == null ? "" : StreamUtil.readText(stream, "utf-8");
|
||||
responseBody = stream == null ? "" : StreamUtil.readText(stream, CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
switch (getResponseType()) {
|
||||
case XML:
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.tasks.impl.httpclient;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -67,7 +82,7 @@ public class ResponseUtil {
|
||||
}
|
||||
else {
|
||||
InputStream stream = response.getResponseBodyAsStream();
|
||||
return stream == null ? "" : StreamUtil.readText(stream, DEFAULT_CHARSET_NAME);
|
||||
return stream == null ? "" : StreamUtil.readText(stream, DEFAULT_CHARSET);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.tasks.youtrack;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.tasks.*;
|
||||
import com.intellij.tasks.impl.BaseRepository;
|
||||
import com.intellij.tasks.impl.BaseRepositoryImpl;
|
||||
@@ -85,7 +101,7 @@ public class YouTrackRepository extends BaseRepositoryImpl {
|
||||
InputStream stream = method.getResponseBodyAsStream();
|
||||
|
||||
// todo workaround for http://youtrack.jetbrains.net/issue/JT-7984
|
||||
String s = StreamUtil.readText(stream, "UTF-8");
|
||||
String s = StreamUtil.readText(stream, CharsetToolkit.UTF8_CHARSET);
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (!XMLChar.isValid(s.charAt(i))) {
|
||||
s = s.replace(s.charAt(i), ' ');
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.plugins.terminal;
|
||||
|
||||
import com.intellij.execution.TaskExecutor;
|
||||
@@ -9,6 +24,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
@@ -37,7 +53,7 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
|
||||
|
||||
public LocalTerminalDirectRunner(Project project) {
|
||||
super(project);
|
||||
myDefaultCharset = Charset.forName("UTF-8");
|
||||
myDefaultCharset = CharsetToolkit.UTF8_CHARSET;
|
||||
}
|
||||
|
||||
private static boolean hasLoginArgument(String name) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.net.NetUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -62,7 +63,7 @@ class OutputTabAdapter extends ProcessAdapter {
|
||||
return;
|
||||
}
|
||||
|
||||
final InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
|
||||
final InputStreamReader reader = new InputStreamReader(stream, CharsetToolkit.UTF8_CHARSET);
|
||||
final HighlightingProcessHandler process = new HighlightingProcessHandler(reader) {
|
||||
private boolean mySelectionChanged;
|
||||
|
||||
|
||||
+12
-15
@@ -21,13 +21,13 @@ import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.vcs.vfs.VcsFileSystem;
|
||||
import com.intellij.openapi.vcs.vfs.VcsVirtualFile;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@SuppressWarnings({ "ComponentNotRegistered" })
|
||||
@@ -43,19 +43,16 @@ public class OpenOutputAction extends AnAction {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Editor editor = CommonDataKeys.EDITOR.getData(DataManager.getInstance().getDataContext(myConsole.getComponent()));
|
||||
if (editor != null) {
|
||||
try {
|
||||
final byte[] content = editor.getDocument().getText().getBytes("UTF-8");
|
||||
final String extension = "xml"; // TODO: get from output type
|
||||
final VcsVirtualFile file = new VcsVirtualFile("XSLT Output." + extension, content, null, VcsFileSystem.getInstance()) {
|
||||
@Override
|
||||
public Charset getCharset() {
|
||||
return Charset.forName("UTF-8");
|
||||
}
|
||||
};
|
||||
FileEditorManager.getInstance(CommonDataKeys.PROJECT.getData(e.getDataContext())).openFile(file, true);
|
||||
} catch (UnsupportedEncodingException e1) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
final byte[] content = editor.getDocument().getText().getBytes(CharsetToolkit.UTF8_CHARSET);
|
||||
final String extension = "xml"; // TODO: get from output type
|
||||
final VcsVirtualFile file = new VcsVirtualFile("XSLT Output." + extension, content, null, VcsFileSystem.getInstance()) {
|
||||
@NotNull
|
||||
@Override
|
||||
public Charset getCharset() {
|
||||
return CharsetToolkit.UTF8_CHARSET;
|
||||
}
|
||||
};
|
||||
FileEditorManager.getInstance(CommonDataKeys.PROJECT.getData(e.getDataContext())).openFile(file, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.TimeoutUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.BaseOutputReader;
|
||||
@@ -25,7 +26,6 @@ import java.io.*;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -468,7 +468,7 @@ public class RemoteDebugger implements ProcessDebugger {
|
||||
synchronized (mySocketObject) {
|
||||
final InputStream myInputStream = socket.getInputStream();
|
||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||
final Reader reader = new InputStreamReader(myInputStream, Charset.forName("UTF-8")); //TODO: correct econding?
|
||||
final Reader reader = new InputStreamReader(myInputStream, CharsetToolkit.UTF8_CHARSET); //TODO: correct econding?
|
||||
return new DebuggerReader(reader);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -122,7 +123,7 @@ public class PyElementGeneratorImpl extends PyElementGenerator {
|
||||
VirtualFile vfile = destination == null ? null : destination.getVirtualFile();
|
||||
Charset charset;
|
||||
if (vfile == null) {
|
||||
charset = (preferUTF8 ? Charset.forName("UTF-8") : Charset.forName("US-ASCII"));
|
||||
charset = (preferUTF8 ? CharsetToolkit.UTF8_CHARSET : Charset.forName("US-ASCII"));
|
||||
}
|
||||
else {
|
||||
charset = vfile.getCharset();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.spellchecker;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.spellchecker.dictionary.Loader;
|
||||
import com.intellij.util.Consumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -25,7 +26,6 @@ import java.io.*;
|
||||
public class StreamLoader implements Loader {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.spellchecker.StreamLoader");
|
||||
private static final String ENCODING = "UTF-8";
|
||||
|
||||
private final InputStream stream;
|
||||
private final String name;
|
||||
@@ -46,7 +46,7 @@ public class StreamLoader implements Loader {
|
||||
BufferedReader br = null;
|
||||
|
||||
try {
|
||||
br = new BufferedReader(new InputStreamReader(in, ENCODING));
|
||||
br = new BufferedReader(new InputStreamReader(in, CharsetToolkit.UTF8_CHARSET));
|
||||
String strLine;
|
||||
while ((strLine = br.readLine()) != null) {
|
||||
consumer.consume(strLine);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.spellchecker.inspector;
|
||||
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.spellchecker.inspections.*;
|
||||
import com.intellij.util.Consumer;
|
||||
import junit.framework.Assert;
|
||||
@@ -388,7 +389,7 @@ public class SplitterTest extends TestCase {
|
||||
String line;
|
||||
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is, CharsetToolkit.UTF8_CHARSET));
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sb.append(line).append("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user