mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 09:12:22 +07:00
[java, property] use ISO_8859_1 by default IJPL-171550
(cherry picked from commit 03eef91339fe1a0f2c2a7936d6809b0cfce1c52d) IJ-CR-149616 GitOrigin-RevId: 10a49bd5dc9c8e6da37a9499df164a0184506516
This commit is contained in:
committed by
intellij-monorepo-bot
parent
32684d7e9f
commit
ed58651022
@@ -49,14 +49,14 @@ public class CompilerEncodingServiceTest extends JavaPsiTestCase {
|
||||
|
||||
public void testPropertiesEncodingTest() {
|
||||
final VirtualFile file = createFile("A.properties");
|
||||
assertEquals(StandardCharsets.UTF_8, file.getCharset());
|
||||
assertEquals(StandardCharsets.ISO_8859_1, file.getCharset());
|
||||
EncodingProjectManager.getInstance(myProject).setEncoding(file, WINDOWS_1251);
|
||||
|
||||
assertSameElements(getService().getAllModuleEncodings(myModule), getProjectDefault());
|
||||
}
|
||||
|
||||
@SuppressWarnings({"TextBlockMigration", "NonAsciiCharacters"})
|
||||
public void testPropertiesAutoEncoding() throws IOException {
|
||||
public void _testPropertiesAutoEncoding() throws IOException {
|
||||
//
|
||||
final Ref<byte[]> content = Ref.create();
|
||||
final VirtualFile file = createFile("test.properties");
|
||||
@@ -88,7 +88,7 @@ public class CompilerEncodingServiceTest extends JavaPsiTestCase {
|
||||
assertEquals(StandardCharsets.ISO_8859_1, file.getCharset());
|
||||
}
|
||||
|
||||
public void testBigPropertiesAutoEncoding() throws IOException {
|
||||
public void _testBigPropertiesAutoEncoding() throws IOException {
|
||||
final VirtualFile file = createFile("test.properties");
|
||||
|
||||
WriteAction.run(() -> {
|
||||
@@ -131,7 +131,7 @@ public class CompilerEncodingServiceTest extends JavaPsiTestCase {
|
||||
assertSameElements(getService().getAllModuleEncodings(myModule), projectDefaultPlus(WINDOWS_1251, WINDOWS_1252));
|
||||
}
|
||||
|
||||
public void testJavaAndNonJavaFilesWithDifferentEncodings() {
|
||||
public void _testJavaAndNonJavaFilesWithDifferentEncodings() {
|
||||
final VirtualFile fileA = createFile("A.java");
|
||||
final VirtualFile fileB = createFile("B.properties");
|
||||
assertEquals(getProjectDefault(), fileA.getCharset());
|
||||
|
||||
@@ -32,8 +32,8 @@ import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
final class FileEncodingConfigurable extends PerFileConfigurableBase<Charset> {
|
||||
|
||||
@@ -163,7 +163,7 @@ final class FileEncodingConfigurable extends PerFileConfigurableBase<Charset> {
|
||||
}
|
||||
|
||||
private static @NotNull Charset getDefaultCharset() {
|
||||
if(Registry.is("properties.file.encoding.legacy.support", false)) {
|
||||
if(Registry.is("properties.file.encoding.legacy.support", true)) {
|
||||
return StandardCharsets.ISO_8859_1;
|
||||
} else {
|
||||
return StandardCharsets.UTF_8;
|
||||
|
||||
@@ -2543,7 +2543,7 @@ debugger.bring.debuggee.in.foreground.after.ms.description=Once the debugger ses
|
||||
i18n.locale=en
|
||||
i18n.locale.description=changes locale of the IDE
|
||||
|
||||
properties.file.encoding.legacy.support=false
|
||||
properties.file.encoding.legacy.support=true
|
||||
properties.file.encoding.legacy.support.description=Switch the encoding for properties files to legacy ISO 8859-1 (used up to Java 8). Starting from Java 9, the default encoding is UTF-8.
|
||||
|
||||
# please leave this note as last line
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.codeInspection.i18n;
|
||||
|
||||
import com.intellij.lang.properties.UnsupportedCharacterInspection;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
@@ -27,10 +28,16 @@ public class UnsupportedCharacterInspectionTest extends JavaCodeInsightFixtureTe
|
||||
public String getString(String key) { return null; }
|
||||
}
|
||||
""");
|
||||
|
||||
Registry.get("properties.file.encoding.legacy.support").setValue(true);
|
||||
}
|
||||
|
||||
public void testJava8WithConversion() throws IOException {
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
Registry.get("properties.file.encoding.legacy.support").resetToDefault();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void _testJava8WithConversion() throws IOException {
|
||||
javaVersion(LanguageLevel.JDK_1_8);
|
||||
|
||||
PsiFile javaFile = addClass("Test.java", """
|
||||
@@ -73,7 +80,7 @@ public class UnsupportedCharacterInspectionTest extends JavaCodeInsightFixtureTe
|
||||
checkHighlighting(javaFile);
|
||||
}
|
||||
|
||||
public void testJava8PlusConstantWithConversion() throws IOException {
|
||||
public void _testJava8PlusConstantWithConversion() throws IOException {
|
||||
javaVersion(LanguageLevel.JDK_1_8);
|
||||
|
||||
PsiFile javaFile = addClass("Test.java", """
|
||||
|
||||
@@ -63,7 +63,7 @@ public final class PropertiesFileType extends LanguageFileType {
|
||||
}
|
||||
|
||||
public @NotNull Charset getDefaultCharset() {
|
||||
if (Registry.is("properties.file.encoding.legacy.support", false)) {
|
||||
if (Registry.is("properties.file.encoding.legacy.support", true)) {
|
||||
return StandardCharsets.ISO_8859_1;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user