diff --git a/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java b/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java index b7d10df7a6cb..afb6a9035a20 100644 --- a/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java +++ b/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java @@ -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 { diff --git a/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java b/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java index 7dede7c97755..8d69635b3cbb 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java +++ b/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java @@ -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); } } } diff --git a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java index bcdd02433832..956108b951f0 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java +++ b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java @@ -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 diff --git a/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java b/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java index 328eda553ac1..c50c7605fbe4 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java +++ b/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java @@ -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)); } }); } diff --git a/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java b/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java index 08f44ab9d3d2..645d861533af 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java +++ b/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java @@ -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 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 diff --git a/java/java-tests/testSrc/com/intellij/TestClassesFilterTest.java b/java/java-tests/testSrc/com/intellij/TestClassesFilterTest.java index 802189ddff83..d7ea86525bde 100644 --- a/java/java-tests/testSrc/com/intellij/TestClassesFilterTest.java +++ b/java/java-tests/testSrc/com/intellij/TestClassesFilterTest.java @@ -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) { diff --git a/java/java-tests/testSrc/com/intellij/psi/SrcRepositoryUseTest.java b/java/java-tests/testSrc/com/intellij/psi/SrcRepositoryUseTest.java index 5ef9f2408e90..bbf4056c70d8 100644 --- a/java/java-tests/testSrc/com/intellij/psi/SrcRepositoryUseTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/SrcRepositoryUseTest.java @@ -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); } diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java index 5ea25a991a06..42ae8be5f958 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java @@ -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 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) { diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java index 26a52c661cf6..3b92d873e8ca 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java @@ -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 pair = quickFixTestCase.parseActionHintImpl(quickFixTestCase.getFile(), contents); diff --git a/platform/core-impl/src/com/intellij/util/CompressionUtil.java b/platform/core-impl/src/com/intellij/util/CompressionUtil.java index 92be79b57f7e..b754c543a5aa 100644 --- a/platform/core-impl/src/com/intellij/util/CompressionUtil.java +++ b/platform/core-impl/src/com/intellij/util/CompressionUtil.java @@ -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; } diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java index b4d45ef03ec8..3fc82be53f46 100644 --- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java +++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java @@ -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 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(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/AbstractExternalFilter.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/AbstractExternalFilter.java index d8d9b7cbbe50..3cc859da0d25 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/AbstractExternalFilter.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/AbstractExternalFilter.java @@ -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; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java index 7e5f84686865..b98ae92731a2 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -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, ("").getBytes("UTF-8"), true); + FileUtil.writeToFile(file, ("").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"); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java index 131c8002af70..66fcefae01f7 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java @@ -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()); } diff --git a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FTManager.java b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FTManager.java index 910dddce6391..0fad9adde99b 100644 --- a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FTManager.java +++ b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FTManager.java @@ -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")){ diff --git a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplatesLoader.java b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplatesLoader.java index 8054891ca0af..6e7deed2b82d 100644 --- a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplatesLoader.java +++ b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplatesLoader.java @@ -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) { diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/EncryptionUtil.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/EncryptionUtil.java index 7bbb8bc80789..37b049c48eb0 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/EncryptionUtil.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/EncryptionUtil.java @@ -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); } /** diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java index 6fa03d5c393e..aa061fa8521e 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java @@ -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() { diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index 0280ed7ce4bd..512ee8729dca 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -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) { diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java index 1087519a8d0f..098bbb8ce552 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java @@ -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) { diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java index 12d5708f9f78..f3e4b137d5e3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java @@ -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)); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/X11UiUtil.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/X11UiUtil.java index 2df2582626b4..4cfa1d02bf5a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/X11UiUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/X11UiUtil.java @@ -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 diff --git a/platform/platform-tests/testSrc/com/intellij/history/integration/IntegrationTestCase.java b/platform/platform-tests/testSrc/com/intellij/history/integration/IntegrationTestCase.java index 61ecc2d15270..e0e7e29018f3 100644 --- a/platform/platform-tests/testSrc/com/intellij/history/integration/IntegrationTestCase.java +++ b/platform/platform-tests/testSrc/com/intellij/history/integration/IntegrationTestCase.java @@ -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)); } diff --git a/platform/platform-tests/testSrc/com/intellij/ide/LocatorTest.java b/platform/platform-tests/testSrc/com/intellij/ide/LocatorTest.java index 09c94c5ef174..efb8cc4b8ddb 100644 --- a/platform/platform-tests/testSrc/com/intellij/ide/LocatorTest.java +++ b/platform/platform-tests/testSrc/com/intellij/ide/LocatorTest.java @@ -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()); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/FileDocumentManagerImplTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/FileDocumentManagerImplTest.java index 4acf5edb5892..de3d6eda6340 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/FileDocumentManagerImplTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/FileDocumentManagerImplTest.java @@ -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()); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilTest.java index 1691a2894f23..753e262b5abd 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilTest.java @@ -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); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java index 1a0d9c37388e..82bda836bf89 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java @@ -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); diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java index 524b9dc31a4b..40d8994e1cb1 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java @@ -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); } diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index 907a3238d564..082351e06892 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -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); diff --git a/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java b/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java index 50419dedb557..8a5be88690e1 100644 --- a/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java +++ b/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java @@ -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 { diff --git a/platform/util/src/com/intellij/openapi/diagnostic/Attachment.java b/platform/util/src/com/intellij/openapi/diagnostic/Attachment.java index 50d8508261ab..df2c3975d673 100644 --- a/platform/util/src/com/intellij/openapi/diagnostic/Attachment.java +++ b/platform/util/src/com/intellij/openapi/diagnostic/Attachment.java @@ -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 diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java index e1ab3edae329..c836c771bea5 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java @@ -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 { diff --git a/platform/util/src/com/intellij/openapi/util/io/StreamUtil.java b/platform/util/src/com/intellij/openapi/util/io/StreamUtil.java index 72754ddf5898..319191e523dd 100644 --- a/platform/util/src/com/intellij/openapi/util/io/StreamUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/StreamUtil.java @@ -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); } diff --git a/platform/util/src/com/intellij/util/ResourceUtil.java b/platform/util/src/com/intellij/util/ResourceUtil.java index a2a857b8687c..390084d1644c 100644 --- a/platform/util/src/com/intellij/util/ResourceUtil.java +++ b/platform/util/src/com/intellij/util/ResourceUtil.java @@ -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]; diff --git a/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java b/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java index d4383a55d03e..bcf2d1d0d77d 100644 --- a/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java +++ b/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java @@ -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() { diff --git a/platform/util/src/com/intellij/util/io/URLUtil.java b/platform/util/src/com/intellij/util/io/URLUtil.java index 1a6e633a3266..f46b7a1884d0 100644 --- a/platform/util/src/com/intellij/util/io/URLUtil.java +++ b/platform/util/src/com/intellij/util/io/URLUtil.java @@ -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; } } diff --git a/platform/util/testSrc/com/intellij/openapi/util/io/FileAttributesReadingTest.java b/platform/util/testSrc/com/intellij/openapi/util/io/FileAttributesReadingTest.java index 752dec025ae0..da4d8618580a 100644 --- a/platform/util/testSrc/com/intellij/openapi/util/io/FileAttributesReadingTest.java +++ b/platform/util/testSrc/com/intellij/openapi/util/io/FileAttributesReadingTest.java @@ -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); diff --git a/platform/util/testSrc/com/intellij/openapi/util/io/IoTestUtil.java b/platform/util/testSrc/com/intellij/openapi/util/io/IoTestUtil.java index 1669c5eca11a..f20aab66b4b0 100644 --- a/platform/util/testSrc/com/intellij/openapi/util/io/IoTestUtil.java +++ b/platform/util/testSrc/com/intellij/openapi/util/io/IoTestUtil.java @@ -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(); } } diff --git a/plugins/coverage/src/com/intellij/coverage/JavaCoverageRunner.java b/plugins/coverage/src/com/intellij/coverage/JavaCoverageRunner.java index 314e07c23a8f..182e26ccc3bf 100644 --- a/plugins/coverage/src/com/intellij/coverage/JavaCoverageRunner.java +++ b/plugins/coverage/src/com/intellij/coverage/JavaCoverageRunner.java @@ -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 { diff --git a/plugins/editorconfig/src/org/editorconfig/configmanagement/EncodingManager.java b/plugins/editorconfig/src/org/editorconfig/configmanagement/EncodingManager.java index 278b684e10d2..3aec6497f144 100644 --- a/plugins/editorconfig/src/org/editorconfig/configmanagement/EncodingManager.java +++ b/plugins/editorconfig/src/org/editorconfig/configmanagement/EncodingManager.java @@ -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 map = new HashMap(); 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); } diff --git a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResourceLocator.java b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResourceLocator.java index 98aedf820084..82cff7dca1cc 100644 --- a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResourceLocator.java +++ b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResourceLocator.java @@ -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))); } } diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java index c0790eb6496b..245dc4ab48ee 100644 --- a/plugins/git4idea/src/git4idea/GitUtil.java +++ b/plugins/git4idea/src/git4idea/GitUtil.java @@ -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"; diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java b/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java index e07755239d45..ceddd8fca5aa 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java @@ -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())) : diff --git a/plugins/git4idea/src/git4idea/commands/GitBinaryHandler.java b/plugins/git4idea/src/git4idea/commands/GitBinaryHandler.java index 7b935044d05e..678cf7120b97 100644 --- a/plugins/git4idea/src/git4idea/commands/GitBinaryHandler.java +++ b/plugins/git4idea/src/git4idea/commands/GitBinaryHandler.java @@ -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 diff --git a/plugins/git4idea/src/git4idea/commands/GitHandler.java b/plugins/git4idea/src/git4idea/commands/GitHandler.java index a1cf820e97db..94389491c9c5 100644 --- a/plugins/git4idea/src/git4idea/commands/GitHandler.java +++ b/plugins/git4idea/src/git4idea/commands/GitHandler.java @@ -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 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; } diff --git a/plugins/git4idea/src/git4idea/commands/GitTextHandler.java b/plugins/git4idea/src/git4idea/commands/GitTextHandler.java index 7dd759f40ebd..1de385c0d4e0 100644 --- a/plugins/git4idea/src/git4idea/commands/GitTextHandler.java +++ b/plugins/git4idea/src/git4idea/commands/GitTextHandler.java @@ -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; } } diff --git a/plugins/git4idea/src/git4idea/config/GitConfigUtil.java b/plugins/git4idea/src/git4idea/config/GitConfigUtil.java index 4870a368c9d3..73be454a7116 100644 --- a/plugins/git4idea/src/git4idea/config/GitConfigUtil.java +++ b/plugins/git4idea/src/git4idea/config/GitConfigUtil.java @@ -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; } diff --git a/plugins/git4idea/src/git4idea/merge/MergeChangeCollector.java b/plugins/git4idea/src/git4idea/merge/MergeChangeCollector.java index c72e738851fa..6402895e08c2 100644 --- a/plugins/git4idea/src/git4idea/merge/MergeChangeCollector.java +++ b/plugins/git4idea/src/git4idea/merge/MergeChangeCollector.java @@ -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) { diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java b/plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java index e159027039b5..798472f162ef 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java +++ b/plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java @@ -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) { diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaser.java b/plugins/git4idea/src/git4idea/rebase/GitRebaser.java index 75e28742b965..d6aee63a9fda 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRebaser.java +++ b/plugins/git4idea/src/git4idea/rebase/GitRebaser.java @@ -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 pickLines = new TreeMap(); - 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(); diff --git a/plugins/git4idea/src/git4idea/stash/GitStashUtils.java b/plugins/git4idea/src/git4idea/stash/GitStashUtils.java index e1da8a349d8a..bc575ce048a0 100644 --- a/plugins/git4idea/src/git4idea/stash/GitStashUtils.java +++ b/plugins/git4idea/src/git4idea/stash/GitStashUtils.java @@ -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 consumer) { GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.STASH.readLockingCommand()); h.setSilent(true); diff --git a/plugins/git4idea/src/git4idea/ui/GitTagDialog.java b/plugins/git4idea/src/git4idea/ui/GitTagDialog.java index 7d1c8f5f4f19..9a6d15c8ab23 100644 --- a/plugins/git4idea/src/git4idea/ui/GitTagDialog.java +++ b/plugins/git4idea/src/git4idea/ui/GitTagDialog.java @@ -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 diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java b/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java index 063ad3bc7bb6..7ac0b46dda15 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java +++ b/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java @@ -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 diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/GithubConnection.java b/plugins/github/src/org/jetbrains/plugins/github/api/GithubConnection.java index 35b4a50c7a7b..3163e3dc63eb 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/GithubConnection.java +++ b/plugins/github/src/org/jetbrains/plugins/github/api/GithubConnection.java @@ -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); } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ManifestGenerationTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ManifestGenerationTest.java index 786cded84d73..65b78491237a 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ManifestGenerationTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ManifestGenerationTest.java @@ -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); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/svnkit/SvnKitDebugLogger.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/svnkit/SvnKitDebugLogger.java index a70658108066..c2b958dd6e7d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/svnkit/SvnKitDebugLogger.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/svnkit/SvnKitDebugLogger.java @@ -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); diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/context/WorkingContextManager.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/context/WorkingContextManager.java index 9aff1234b3af..66054c8f0429 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/context/WorkingContextManager.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/context/WorkingContextManager.java @@ -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); diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepository.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepository.java index 566191172e58..0dae8cf2429d 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepository.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepository.java @@ -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: diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/httpclient/ResponseUtil.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/httpclient/ResponseUtil.java index bb040139a9e4..e512ff04a15b 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/httpclient/ResponseUtil.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/httpclient/ResponseUtil.java @@ -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); } } diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackRepository.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackRepository.java index 2093a179b461..5da18ef96d21 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackRepository.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackRepository.java @@ -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), ' '); diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java index 8a5f75b36594..55aef7a7c9f0 100644 --- a/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java +++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java @@ -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