mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -32,10 +32,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -274,7 +271,7 @@ public class GenerateAntBuildAction extends CompileActionBase {
|
||||
* @throws FileNotFoundException if file not found
|
||||
*/
|
||||
private static PrintWriter makeWriter(final File buildxmlFile) throws UnsupportedEncodingException, FileNotFoundException {
|
||||
return new PrintWriter(new OutputStreamWriter(new FileOutputStream(buildxmlFile), "UTF-8"));
|
||||
return new PrintWriter(new OutputStreamWriter(new FileOutputStream(buildxmlFile), CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
|
||||
private void ensureFilesWritable(Project project, File[] files) throws IOException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-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.
|
||||
@@ -104,8 +104,7 @@ import org.jetbrains.jps.cmdline.ClasspathBootstrap;
|
||||
import org.jetbrains.jps.incremental.Utils;
|
||||
import org.jetbrains.jps.model.serialization.JpsGlobalLoader;
|
||||
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.ToolProvider;
|
||||
import javax.tools.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -211,14 +210,13 @@ public class BuildManager implements ApplicationComponent{
|
||||
|
||||
private final BuildMessageDispatcher myMessageDispatcher = new BuildMessageDispatcher();
|
||||
private volatile int myListenPort = -1;
|
||||
@Nullable
|
||||
private final Charset mySystemCharset;
|
||||
@NotNull
|
||||
private final Charset mySystemCharset = CharsetToolkit.getDefaultSystemCharset();
|
||||
|
||||
public BuildManager(final ProjectManager projectManager) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
IS_UNIT_TEST_MODE = application.isUnitTestMode();
|
||||
myProjectManager = projectManager;
|
||||
mySystemCharset = CharsetToolkit.getDefaultSystemCharset();
|
||||
final String systemPath = PathManager.getSystemPath();
|
||||
File system = new File(systemPath);
|
||||
try {
|
||||
@@ -994,10 +992,8 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
|
||||
// javac's VM should use the same default locale that IDEA uses in order for javac to print messages in 'correct' language
|
||||
if (mySystemCharset != null) {
|
||||
cmdLine.setCharset(mySystemCharset);
|
||||
cmdLine.addParameter("-D" + CharsetToolkit.FILE_ENCODING_PROPERTY + "=" + mySystemCharset.name());
|
||||
}
|
||||
cmdLine.setCharset(mySystemCharset);
|
||||
cmdLine.addParameter("-D" + CharsetToolkit.FILE_ENCODING_PROPERTY + "=" + mySystemCharset.name());
|
||||
cmdLine.addParameter("-D" + JpsGlobalLoader.FILE_TYPES_COMPONENT_NAME_KEY + "=" + FileTypeManagerImpl.getFileTypeComponentName());
|
||||
for (String name : new String[]{"user.language", "user.country", "user.region", PathManager.PROPERTY_PATHS_SELECTOR}) {
|
||||
final String value = System.getProperty(name);
|
||||
|
||||
+2
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -107,9 +107,7 @@ public class JavaParameters extends SimpleJavaParameters {
|
||||
|
||||
public void setDefaultCharset(final Project project) {
|
||||
Charset encoding = EncodingProjectManager.getInstance(project).getDefaultCharset();
|
||||
if (encoding != null) {
|
||||
setCharset(encoding);
|
||||
}
|
||||
setCharset(encoding);
|
||||
}
|
||||
|
||||
public void configureByModule(final Module module,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
@@ -104,7 +105,7 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate {
|
||||
ZipEntry entry;
|
||||
while ((entry = stream.getNextEntry()) != null) {
|
||||
if (condition.value(entry)) {
|
||||
return StreamUtil.readText(stream, TemplateModuleBuilder.UTF_8);
|
||||
return StreamUtil.readText(stream, CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.module.ModuleTypeManager;
|
||||
import com.intellij.openapi.util.ClearableLazyValue;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.platform.ProjectTemplate;
|
||||
import com.intellij.platform.ProjectTemplatesFactory;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -92,7 +93,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
|
||||
try {
|
||||
connection = getConnection(code + "_templates.xml");
|
||||
stream = connection.getInputStream();
|
||||
String text = StreamUtil.readText(stream, TemplateModuleBuilder.UTF_8);
|
||||
String text = StreamUtil.readText(stream, CharsetToolkit.UTF8_CHARSET);
|
||||
return createFromText(text);
|
||||
}
|
||||
catch (IOException ex) { // timeouts, lost connection etc
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,6 +42,7 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -177,7 +178,7 @@ public class SaveProjectAsTemplateAction extends AnAction {
|
||||
public InputStream getContent(final File file) throws IOException {
|
||||
if (virtualFile.getFileType().isBinary() || PROJECT_TEMPLATE_XML.equals(virtualFile.getName())) return STANDARD.getContent(file);
|
||||
String result = getEncodedContent(virtualFile, project, parameters);
|
||||
return new ByteArrayInputStream(result.getBytes(TemplateModuleBuilder.UTF_8));
|
||||
return new ByteArrayInputStream(result.getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -66,8 +66,6 @@ import java.util.zip.ZipInputStream;
|
||||
*/
|
||||
public class TemplateModuleBuilder extends ModuleBuilder {
|
||||
|
||||
public static final String UTF_8 = "UTF-8";
|
||||
|
||||
private final ModuleType myType;
|
||||
private List<WizardInputField> myAdditionalFields;
|
||||
private ArchivedProjectTemplate myTemplate;
|
||||
@@ -272,7 +270,8 @@ public class TemplateModuleBuilder extends ModuleBuilder {
|
||||
properties.put(ProjectTemplateParameterFactory.IJ_PROJECT_NAME, projectName);
|
||||
}
|
||||
String merged = FileTemplateUtil.mergeTemplate(properties, content, true);
|
||||
return StringUtilRt.convertLineSeparators(merged.replace("\\$", "$").replace("\\#", "#"), SystemInfo.isWindows ? "\r\n" : "\n").getBytes(UTF_8);
|
||||
return StringUtilRt.convertLineSeparators(merged.replace("\\$", "$").replace("\\#", "#"), SystemInfo.isWindows ? "\r\n" : "\n").getBytes(
|
||||
CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
|
||||
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(callExpression.getProject());
|
||||
final PsiMethodReferenceExpression methodReferenceExpression =
|
||||
(PsiMethodReferenceExpression)elementFactory.createExpressionFromText(methodReferenceText, callExpression);
|
||||
final Map<PsiMethodReferenceExpression, PsiType> map = PsiMethodReferenceUtil.getFunctionalTypeMap();
|
||||
final Map<PsiElement, PsiType> map = LambdaUtil.getFunctionalTypeMap();
|
||||
try {
|
||||
map.put(methodReferenceExpression, functionalInterfaceType);
|
||||
final JavaResolveResult result = methodReferenceExpression.advancedResolve(false);
|
||||
|
||||
+2
-3
@@ -50,9 +50,8 @@ public class MethodReferenceCompletionProvider extends CompletionProvider<Comple
|
||||
final PsiElement position = parameters.getPosition();
|
||||
final PsiElement refPlace = position.getParent();
|
||||
final ExpectedTypeInfoImpl typeInfo =
|
||||
new ExpectedTypeInfoImpl(returnType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, returnType, TailType.UNKNOWN, null,
|
||||
ExpectedTypeInfoImpl.NULL);
|
||||
final Map<PsiMethodReferenceExpression, PsiType> map = PsiMethodReferenceUtil.getFunctionalTypeMap();
|
||||
new ExpectedTypeInfoImpl(returnType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, returnType, TailType.UNKNOWN, null, ExpectedTypeInfoImpl.NULL);
|
||||
final Map<PsiElement, PsiType> map = LambdaUtil.getFunctionalTypeMap();
|
||||
Consumer<LookupElement> noTypeCheck = new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(final LookupElement lookupElement) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.infos.MethodCandidateInfo;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -286,6 +287,15 @@ public class LambdaUtil {
|
||||
element = parent;
|
||||
parent = parent.getParent();
|
||||
}
|
||||
|
||||
final Map<PsiElement, PsiType> map = ourFunctionTypes.get();
|
||||
if (map != null) {
|
||||
final PsiType type = map.get(expression);
|
||||
if (type != null) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
if (parent instanceof PsiArrayInitializerExpression) {
|
||||
final PsiType psiType = ((PsiArrayInitializerExpression)parent).getType();
|
||||
if (psiType instanceof PsiArrayType) {
|
||||
@@ -327,13 +337,6 @@ public class LambdaUtil {
|
||||
return properties.getSubstitutor().substitute(getNormalizedType(parameters[finalLambdaIdx]));
|
||||
}
|
||||
}
|
||||
final Map<PsiElement, PsiType> map = ourFunctionTypes.get();
|
||||
if (map != null) {
|
||||
final PsiType type = map.get(expression);
|
||||
if (type != null) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
final JavaResolveResult resolveResult = contextCall.resolveMethodGenerics();
|
||||
final PsiElement resolve = resolveResult.getElement();
|
||||
if (resolve instanceof PsiMethod) {
|
||||
@@ -518,7 +521,17 @@ public class LambdaUtil {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static Map<PsiElement, PsiType> getFunctionalTypeMap() {
|
||||
Map<PsiElement, PsiType> map = ourFunctionTypes.get();
|
||||
if (map == null) {
|
||||
map = new HashMap<PsiElement, PsiType>();
|
||||
ourFunctionTypes.set(map);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static class TypeParamsChecker extends PsiTypeVisitor<Boolean> {
|
||||
private PsiMethod myMethod;
|
||||
private final PsiClass myClass;
|
||||
|
||||
@@ -27,8 +27,6 @@ import java.util.Map;
|
||||
* User: anna
|
||||
*/
|
||||
public class PsiMethodReferenceUtil {
|
||||
public static ThreadLocal<Map<PsiMethodReferenceExpression, PsiType>> ourRefs = new ThreadLocal<Map<PsiMethodReferenceExpression, PsiType>>();
|
||||
|
||||
public static final Logger LOG = Logger.getInstance("#" + PsiMethodReferenceUtil.class.getName());
|
||||
|
||||
public static boolean hasReceiver(PsiType[] parameterTypes, QualifierResolveResult qualifierResolveResult, PsiMethodReferenceExpression methodRef) {
|
||||
@@ -97,16 +95,6 @@ public class PsiMethodReferenceUtil {
|
||||
return !varargs || parameterTypes.length - 1 <= argTypes.length - offset;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Map<PsiMethodReferenceExpression, PsiType> getFunctionalTypeMap() {
|
||||
Map<PsiMethodReferenceExpression, PsiType> map = ourRefs.get();
|
||||
if (map == null) {
|
||||
map = new HashMap<PsiMethodReferenceExpression, PsiType>();
|
||||
ourRefs.set(map);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static class QualifierResolveResult {
|
||||
private final PsiClass myContainingClass;
|
||||
private final PsiSubstitutor mySubstitutor;
|
||||
|
||||
@@ -746,8 +746,8 @@ public class PsiImplUtil {
|
||||
return JavaResolveResult.EMPTY_ARRAY;
|
||||
}
|
||||
if (element instanceof PsiMethodReferenceExpression) {
|
||||
// method refs: do not cache results during parent conflict resolving
|
||||
final Map<PsiMethodReferenceExpression, PsiType> map = PsiMethodReferenceUtil.ourRefs.get();
|
||||
// method refs: do not cache results during parent conflict resolving, acceptable checks, etc
|
||||
final Map<PsiElement, PsiType> map = LambdaUtil.ourFunctionTypes.get();
|
||||
if (map != null && map.containsKey(element)) {
|
||||
return (JavaResolveResult[])resolver.resolve(element, psiFile, incompleteCode);
|
||||
}
|
||||
|
||||
+1
-2
@@ -311,8 +311,7 @@ public class InferenceSession {
|
||||
expression = PsiUtil.skipParenthesizedExprDown(expression);
|
||||
if (expression instanceof PsiConditionalExpression ||
|
||||
expression instanceof PsiCallExpression ||
|
||||
expression instanceof PsiLambdaExpression ||
|
||||
expression instanceof PsiMethodReferenceExpression) {
|
||||
expression instanceof PsiFunctionalExpression) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-3
@@ -30,8 +30,7 @@ import java.util.Set;
|
||||
*/
|
||||
public class PsiPolyExpressionUtil {
|
||||
public static boolean hasStandaloneForm(PsiExpression expression) {
|
||||
if (expression instanceof PsiLambdaExpression ||
|
||||
expression instanceof PsiMethodReferenceExpression ||
|
||||
if (expression instanceof PsiFunctionalExpression ||
|
||||
expression instanceof PsiParenthesizedExpression ||
|
||||
expression instanceof PsiConditionalExpression ||
|
||||
expression instanceof PsiCallExpression) {
|
||||
@@ -41,7 +40,7 @@ public class PsiPolyExpressionUtil {
|
||||
}
|
||||
|
||||
public static boolean isPolyExpression(final PsiExpression expression) {
|
||||
if (expression instanceof PsiLambdaExpression || expression instanceof PsiMethodReferenceExpression) {
|
||||
if (expression instanceof PsiFunctionalExpression) {
|
||||
return true;
|
||||
}
|
||||
else if (expression instanceof PsiParenthesizedExpression) {
|
||||
|
||||
+2
-7
@@ -42,7 +42,7 @@ public abstract class InputOutputConstraintFormula implements ConstraintFormula
|
||||
public Set<InferenceVariable> getInputVariables(InferenceSession session) {
|
||||
final PsiExpression psiExpression = getExpression();
|
||||
final PsiType type = getT();
|
||||
if (psiExpression instanceof PsiLambdaExpression || psiExpression instanceof PsiMethodReferenceExpression) {
|
||||
if (psiExpression instanceof PsiFunctionalExpression) {
|
||||
final InferenceVariable inferenceVariable = session.getInferenceVariable(type);
|
||||
if (inferenceVariable != null) {
|
||||
return Collections.singleton(inferenceVariable);
|
||||
@@ -112,12 +112,7 @@ public abstract class InputOutputConstraintFormula implements ConstraintFormula
|
||||
public void apply(PsiSubstitutor substitutor, boolean cache) {
|
||||
setT(substitutor.substitute(getT()));
|
||||
if (cache) {
|
||||
Map<PsiElement, PsiType> map = LambdaUtil.ourFunctionTypes.get();
|
||||
if (map == null) {
|
||||
map = new HashMap<PsiElement, PsiType>();
|
||||
LambdaUtil.ourFunctionTypes.set(map);
|
||||
}
|
||||
map.put(getExpression(), getT());
|
||||
LambdaUtil.getFunctionalTypeMap().put(getExpression(), getT());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -21,7 +21,6 @@ import com.intellij.psi.impl.source.resolve.graphInference.FunctionalInterfacePa
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil;
|
||||
import com.intellij.psi.infos.MethodCandidateInfo;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
@@ -124,7 +123,7 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
||||
return true;
|
||||
}
|
||||
|
||||
final Map<PsiMethodReferenceExpression, PsiType> map = PsiMethodReferenceUtil.getFunctionalTypeMap();
|
||||
final Map<PsiElement, PsiType> map = LambdaUtil.getFunctionalTypeMap();
|
||||
final PsiType added = map.put(myExpression, session.startWithFreshVars(groundTargetType));
|
||||
final JavaResolveResult resolve;
|
||||
try {
|
||||
|
||||
+1
-11
@@ -174,17 +174,7 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
|
||||
}
|
||||
|
||||
protected PsiType getInterfaceType(PsiMethodReferenceExpression reference) {
|
||||
PsiType functionalInterfaceType = null;
|
||||
final Map<PsiMethodReferenceExpression,PsiType> map = PsiMethodReferenceUtil.ourRefs.get();
|
||||
if (map != null) {
|
||||
functionalInterfaceType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(map.get(reference));
|
||||
}
|
||||
|
||||
if (functionalInterfaceType == null) {
|
||||
functionalInterfaceType = reference.getFunctionalInterfaceType();
|
||||
}
|
||||
|
||||
return functionalInterfaceType;
|
||||
return reference.getFunctionalInterfaceType();
|
||||
}
|
||||
|
||||
protected PsiConflictResolver createResolver(PsiMethodReferenceExpressionImpl referenceExpression,
|
||||
|
||||
+5
-18
@@ -181,11 +181,6 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
leftType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(leftType, this);
|
||||
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(leftType);
|
||||
final PsiClass psiClass = resolveResult.getElement();
|
||||
if (psiClass instanceof PsiAnonymousClass) {
|
||||
return isAcceptable(((PsiAnonymousClass)psiClass).getBaseClassType());
|
||||
}
|
||||
|
||||
if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList)) {
|
||||
final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(argsList);
|
||||
if (candidateProperties != null) {
|
||||
@@ -200,13 +195,6 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
}
|
||||
}
|
||||
|
||||
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
|
||||
|
||||
if (interfaceMethod == null) return false;
|
||||
|
||||
final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, resolveResult);
|
||||
|
||||
assert leftType != null;
|
||||
if (!isPotentiallyCompatible(leftType)) {
|
||||
return false;
|
||||
}
|
||||
@@ -215,7 +203,10 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
|
||||
if (interfaceMethod == null) return false;
|
||||
|
||||
final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, resolveResult);
|
||||
|
||||
if (hasFormalParameterTypes()) {
|
||||
final PsiParameter[] lambdaParameters = getParameterList().getParameters();
|
||||
@@ -235,11 +226,7 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
|
||||
PsiType methodReturnType = interfaceMethod.getReturnType();
|
||||
if (methodReturnType != null && methodReturnType != PsiType.VOID) {
|
||||
Map<PsiElement, PsiType> map = LambdaUtil.ourFunctionTypes.get();
|
||||
if (map == null) {
|
||||
map = new HashMap<PsiElement, PsiType>();
|
||||
LambdaUtil.ourFunctionTypes.set(map);
|
||||
}
|
||||
Map<PsiElement, PsiType> map = LambdaUtil.getFunctionalTypeMap();
|
||||
try {
|
||||
if (map.put(this, leftType) != null) {
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -409,7 +409,7 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
// the result of applying capture conversion (5.1.10) to the return type of the invocation type (15.12.2.6) of the chosen declaration is R',
|
||||
// where R is the target type that may be used to infer R'; neither R nor R' is void; and R' is compatible with R in an assignment context.
|
||||
|
||||
Map<PsiMethodReferenceExpression, PsiType> map = PsiMethodReferenceUtil.getFunctionalTypeMap();
|
||||
Map<PsiElement, PsiType> map = LambdaUtil.getFunctionalTypeMap();
|
||||
final JavaResolveResult result;
|
||||
try {
|
||||
if (map.put(this, left) != null) {
|
||||
|
||||
+1
-1
@@ -761,7 +761,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
return thenSpecifics == elseSpecifics ? thenSpecifics : Specifics.NEITHER;
|
||||
}
|
||||
|
||||
if (expr instanceof PsiLambdaExpression || expr instanceof PsiMethodReferenceExpression) {
|
||||
if (expr instanceof PsiFunctionalExpression) {
|
||||
|
||||
if (expr instanceof PsiLambdaExpression && !((PsiLambdaExpression)expr).hasFormalParameterTypes()) {
|
||||
return Specifics.NEITHER;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -98,7 +99,7 @@ public class TestClassesFilterTest {
|
||||
}
|
||||
|
||||
private static InputStreamReader getReader(String filterText) throws UnsupportedEncodingException {
|
||||
return new InputStreamReader(new ByteArrayInputStream(filterText.getBytes("UTF-8")));
|
||||
return new InputStreamReader(new ByteArrayInputStream(filterText.getBytes(CharsetToolkit.UTF8_CHARSET)));
|
||||
}
|
||||
|
||||
private static void checkForAllExcludedDefinedGroup(TestClassesFilter classesFilter) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,12 +20,12 @@ import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.projectRoots.impl.ProjectRootUtil;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
@@ -801,7 +801,7 @@ public class SrcRepositoryUseTest extends PsiTestCase{
|
||||
}
|
||||
|
||||
private static void rewriteFileExternally(VirtualFile vFile, String text) throws IOException {
|
||||
FileUtil.writeToFile(new File(vFile.getPath()), text.getBytes("UTF-8"));
|
||||
FileUtil.writeToFile(new File(vFile.getPath()), text.getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
vFile.refresh(false, false);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@ import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -58,7 +59,7 @@ public abstract class AbstractJavaFormatterTest extends LightIdeaTestCase {
|
||||
StringBuilder result = new StringBuilder(initial.length());
|
||||
List<byte[]> lines;
|
||||
try {
|
||||
LineReader reader = new LineReader(new ByteArrayInputStream(initial.getBytes("UTF-8")));
|
||||
LineReader reader = new LineReader(new ByteArrayInputStream(initial.getBytes(CharsetToolkit.UTF8_CHARSET)));
|
||||
lines = reader.readLines();
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
String contents = StringUtil.convertLineSeparators(FileUtil.loadFile(testFile, CharsetToolkit.UTF8));
|
||||
String contents = StringUtil.convertLineSeparators(FileUtil.loadFile(testFile, CharsetToolkit.UTF8_CHARSET));
|
||||
quickFixTestCase.configureFromFileText(testFile.getName(), contents);
|
||||
quickFixTestCase.bringRealEditorBack();
|
||||
final Pair<String, Boolean> pair = quickFixTestCase.parseActionHintImpl(quickFixTestCase.getFile(), contents);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,6 +28,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
* <p/>
|
||||
* Implement {@link com.intellij.openapi.util.Iconable Iconable} interface to
|
||||
* change icon in intention popup menu.
|
||||
* <p/>
|
||||
* Implement {@link com.intellij.codeInsight.intention.HighPriorityAction HighPriorityAction} or
|
||||
* {@link com.intellij.codeInsight.intention.LowPriorityAction LowPriorityAction} to change ordering.
|
||||
*
|
||||
* @see IntentionManager#registerIntentionAndMetaData(com.intellij.codeInsight.intention.IntentionAction, java.lang.String...)
|
||||
*/
|
||||
|
||||
@@ -17,15 +17,18 @@ package com.intellij.codeInspection;
|
||||
|
||||
/**
|
||||
* QuickFix based on {@link com.intellij.codeInspection.ProblemDescriptor ProblemDescriptor}
|
||||
*
|
||||
* Implement {@link com.intellij.openapi.util.Iconable Iconable} interface to
|
||||
* change icon in quick fix popup menu
|
||||
*
|
||||
* <p/>
|
||||
* N.B. Please DO NOT store PSI elements inside the LocalQuickFix instance, to avoid holding too much PSI files during inspection.
|
||||
* Instead, use the {@link ProblemDescriptor#getPsiElement()}
|
||||
* in {@link QuickFix#applyFix(com.intellij.openapi.project.Project, CommonProblemDescriptor)}
|
||||
* to retrieve the PSI context the fix will work on.
|
||||
* See also {@link LocalQuickFixOnPsiElement} which uses {@link com.intellij.psi.SmartPsiElementPointer} instead of storing PSI elements.
|
||||
* <p/>
|
||||
* Implement {@link com.intellij.openapi.util.Iconable Iconable} interface to
|
||||
* change icon in quick fix popup menu.
|
||||
* <p/>
|
||||
* Implement {@link com.intellij.codeInsight.intention.HighPriorityAction HighPriorityAction} or
|
||||
* {@link com.intellij.codeInsight.intention.LowPriorityAction LowPriorityAction} to change ordering.
|
||||
*
|
||||
* @author max
|
||||
* @see LocalQuickFixBase
|
||||
|
||||
@@ -506,6 +506,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
|
||||
/**
|
||||
* @return Retrieve the charset file has been loaded with (if loaded) and would be saved with (if would).
|
||||
*/
|
||||
@NotNull
|
||||
public Charset getCharset() {
|
||||
Charset charset = getStoredCharset();
|
||||
if (charset == null) {
|
||||
|
||||
+4
-12
@@ -42,19 +42,14 @@ public abstract class EncodingManager extends EncodingRegistry {
|
||||
@NotNull
|
||||
public abstract Collection<Charset> getFavorites();
|
||||
|
||||
@Deprecated // does nothing
|
||||
public abstract void setUseUTFGuessing(VirtualFile virtualFile, boolean useUTFGuessing);
|
||||
|
||||
@Override
|
||||
public abstract boolean isNative2AsciiForPropertiesFiles();
|
||||
|
||||
public abstract void setNative2AsciiForPropertiesFiles(VirtualFile virtualFile, boolean native2Ascii);
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
// returns empty for system default
|
||||
public String getDefaultCharsetName() {
|
||||
Charset charset = getDefaultCharset();
|
||||
return charset == null ? null : charset.displayName();
|
||||
}
|
||||
public abstract String getDefaultCharsetName();
|
||||
|
||||
public void setDefaultCharsetName(@NotNull String name) {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
@@ -63,14 +58,11 @@ public abstract class EncodingManager extends EncodingRegistry {
|
||||
/**
|
||||
* @return null for system-default
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public abstract Charset getDefaultCharsetForPropertiesFiles(@Nullable VirtualFile virtualFile);
|
||||
public abstract void setDefaultCharsetForPropertiesFiles(@Nullable VirtualFile virtualFile, @Nullable Charset charset);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link EncodingManager#addPropertyChangeListener(java.beans.PropertyChangeListener, com.intellij.openapi.Disposable)} instead
|
||||
*/
|
||||
public abstract void addPropertyChangeListener(@NotNull PropertyChangeListener listener);
|
||||
public abstract void addPropertyChangeListener(@NotNull PropertyChangeListener listener, @NotNull Disposable parentDisposable);
|
||||
|
||||
public abstract void removePropertyChangeListener(@NotNull PropertyChangeListener listener);
|
||||
+19
@@ -35,4 +35,23 @@ public abstract class EncodingProjectManager extends EncodingManager {
|
||||
|
||||
public abstract void setMapping(@NotNull Map<VirtualFile, Charset> result);
|
||||
|
||||
/**
|
||||
* @return Project encoding name (configured in Settings|File Encodings|Project Encoding) or empty string if it's configured to "System Default"
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public abstract String getDefaultCharsetName();
|
||||
|
||||
/**
|
||||
* @return Project encoding (configured in Settings|File Encodings|Project Encoding)
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public abstract Charset getDefaultCharset();
|
||||
|
||||
/**
|
||||
* Sets Project encoding (configured in Settings|File Encodings|Project Encoding). Use empty string to specify "System Default"
|
||||
*/
|
||||
@Override
|
||||
public abstract void setDefaultCharsetName(@NotNull String name);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public abstract class EncodingRegistry {
|
||||
/**
|
||||
* @return charset configured in Settings|File Encodings|IDE encoding
|
||||
*/
|
||||
@Nullable
|
||||
@NotNull
|
||||
public abstract Charset getDefaultCharset();
|
||||
|
||||
/**
|
||||
|
||||
@@ -254,7 +254,7 @@ public class LightVirtualFile extends VirtualFile {
|
||||
public byte[] contentsToByteArray() throws IOException {
|
||||
final Charset charset = getCharset();
|
||||
final String s = getContent().toString();
|
||||
return charset != null ? s.getBytes(charset.name()) : s.getBytes();
|
||||
return s.getBytes(charset.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,6 +32,7 @@ public class CoreEncodingRegistry extends EncodingRegistry {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Charset getDefaultCharset() {
|
||||
return CharsetToolkit.getDefaultSystemCharset();
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.intellij.lang.impl;
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -1111,7 +1112,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
final MyComparator comparator = new MyComparator(getUserDataUnprotected(CUSTOM_COMPARATOR), treeStructure);
|
||||
|
||||
final ProgressIndicator indicator = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
BlockSupportImpl.diffTrees(oldRoot, builder, comparator, treeStructure, indicator);
|
||||
BlockSupportImpl.diffTrees(oldRoot, builder, comparator, treeStructure, indicator == null ? new EmptyProgressIndicator() : indicator);
|
||||
return diffLog;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,12 @@ import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingRegistry;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -121,6 +123,7 @@ public final class LoadTextUtil {
|
||||
return Pair.create(result, detectedLineSeparator);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Charset detectCharset(@NotNull VirtualFile virtualFile, @NotNull byte[] content, @NotNull FileType fileType) {
|
||||
Charset charset = null;
|
||||
|
||||
@@ -142,7 +145,9 @@ public final class LoadTextUtil {
|
||||
}
|
||||
}
|
||||
|
||||
charset = charset == null ? EncodingRegistry.getInstance().getDefaultCharset() : charset;
|
||||
if (charset == null) {
|
||||
charset = EncodingRegistry.getInstance().getDefaultCharset();
|
||||
}
|
||||
if (fileType.getName().equals("Properties") && EncodingRegistry.getInstance().isNative2AsciiForPropertiesFiles()) {
|
||||
charset = Native2AsciiCharset.wrap(charset);
|
||||
}
|
||||
@@ -156,15 +161,15 @@ public final class LoadTextUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Pair<Charset, byte[]> doDetectCharsetAndSetBOM(@NotNull VirtualFile virtualFile, @NotNull byte[] content, boolean saveBOM) {
|
||||
private static Pair.NonNull<Charset, byte[]> doDetectCharsetAndSetBOM(@NotNull VirtualFile virtualFile, @NotNull byte[] content, boolean saveBOM) {
|
||||
return doDetectCharsetAndSetBOM(virtualFile, content, saveBOM, virtualFile.getFileType());
|
||||
}
|
||||
@NotNull
|
||||
private static Pair<Charset, byte[]> doDetectCharsetAndSetBOM(@NotNull VirtualFile virtualFile, @NotNull byte[] content, boolean saveBOM, @NotNull FileType fileType) {
|
||||
Charset charset = virtualFile.isCharsetSet() ? virtualFile.getCharset() : detectCharset(virtualFile, content,fileType);
|
||||
Pair<Charset,byte[]> bomAndCharset = getBOMAndCharset(content, charset);
|
||||
private static Pair.NonNull<Charset, byte[]> doDetectCharsetAndSetBOM(@NotNull VirtualFile virtualFile, @NotNull byte[] content, boolean saveBOM, @NotNull FileType fileType) {
|
||||
@NotNull Charset charset = virtualFile.isCharsetSet() ? virtualFile.getCharset() : detectCharset(virtualFile, content,fileType);
|
||||
Pair.NonNull<Charset, byte[]> bomAndCharset = getCharsetAndBOM(content, charset);
|
||||
final byte[] bom = bomAndCharset.second;
|
||||
if (saveBOM && bom != null && bom.length != 0) {
|
||||
if (saveBOM && bom.length != 0) {
|
||||
virtualFile.setBOM(bom);
|
||||
setCharsetWasDetectedFromBytes(virtualFile, AUTO_DETECTED_FROM_BOM);
|
||||
}
|
||||
@@ -175,7 +180,8 @@ public final class LoadTextUtil {
|
||||
|
||||
@Nullable("null means no luck, otherwise it's tuple(guessed encoding, hint about content if was unable to guess, BOM)")
|
||||
public static Trinity<Charset, CharsetToolkit.GuessedEncoding, byte[]> guessFromContent(@NotNull VirtualFile virtualFile, @NotNull byte[] content, int length) {
|
||||
CharsetToolkit toolkit = GUESS_UTF ? new CharsetToolkit(content, EncodingRegistry.getInstance().getDefaultCharset()) : null;
|
||||
Charset defaultCharset = ObjectUtils.notNull(EncodingManager.getInstance().getEncoding(virtualFile, true), CharsetToolkit.getDefaultSystemCharset());
|
||||
CharsetToolkit toolkit = GUESS_UTF ? new CharsetToolkit(content, defaultCharset) : null;
|
||||
String detectedFromBytes = null;
|
||||
try {
|
||||
if (GUESS_UTF) {
|
||||
@@ -183,8 +189,7 @@ public final class LoadTextUtil {
|
||||
Charset charset = toolkit.guessFromBOM();
|
||||
if (charset != null) {
|
||||
detectedFromBytes = AUTO_DETECTED_FROM_BOM;
|
||||
byte[] bom = CharsetToolkit.getMandatoryBom(charset);
|
||||
if (bom == null) bom = CharsetToolkit.UTF8_BOM;
|
||||
byte[] bom = ObjectUtils.notNull(CharsetToolkit.getMandatoryBom(charset), CharsetToolkit.UTF8_BOM);
|
||||
return Trinity.create(charset, null, bom);
|
||||
}
|
||||
CharsetToolkit.GuessedEncoding guessed = toolkit.guessFromContent(length);
|
||||
@@ -204,20 +209,20 @@ public final class LoadTextUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Pair<Charset,byte[]> getBOMAndCharset(@NotNull byte[] content, final Charset charset) {
|
||||
if (charset != null && charset.name().contains(CharsetToolkit.UTF8) && CharsetToolkit.hasUTF8Bom(content)) {
|
||||
return Pair.create(charset, CharsetToolkit.UTF8_BOM);
|
||||
private static Pair.NonNull<Charset,byte[]> getCharsetAndBOM(@NotNull byte[] content, @NotNull Charset charset) {
|
||||
if (charset.name().contains(CharsetToolkit.UTF8) && CharsetToolkit.hasUTF8Bom(content)) {
|
||||
return Pair.createNonNull(charset, CharsetToolkit.UTF8_BOM);
|
||||
}
|
||||
try {
|
||||
Charset fromBOM = CharsetToolkit.guessFromBOM(content);
|
||||
if (fromBOM != null) {
|
||||
return Pair.create(fromBOM, CharsetToolkit.getMandatoryBom(fromBOM));
|
||||
return Pair.createNonNull(fromBOM, ObjectUtils.notNull(CharsetToolkit.getMandatoryBom(fromBOM), ArrayUtil.EMPTY_BYTE_ARRAY));
|
||||
}
|
||||
}
|
||||
catch (UnsupportedCharsetException ignore) {
|
||||
}
|
||||
|
||||
return Pair.create(charset, ArrayUtil.EMPTY_BYTE_ARRAY);
|
||||
return Pair.createNonNull(charset, ArrayUtil.EMPTY_BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public static void changeLineSeparators(@Nullable Project project,
|
||||
@@ -254,13 +259,11 @@ public final class LoadTextUtil {
|
||||
@NotNull String text,
|
||||
long newModificationStamp) throws IOException {
|
||||
Charset existing = virtualFile.getCharset();
|
||||
Pair<Charset, byte[]> chosen = charsetForWriting(project, virtualFile, text, existing);
|
||||
Pair.NonNull<Charset, byte[]> chosen = charsetForWriting(project, virtualFile, text, existing);
|
||||
Charset charset = chosen.first;
|
||||
byte[] buffer = chosen.second;
|
||||
if (charset != null) {
|
||||
if (!charset.equals(existing)) {
|
||||
virtualFile.setCharset(charset);
|
||||
}
|
||||
if (!charset.equals(existing)) {
|
||||
virtualFile.setCharset(charset);
|
||||
}
|
||||
setDetectedFromBytesFlagBack(virtualFile, buffer);
|
||||
|
||||
@@ -274,12 +277,12 @@ public final class LoadTextUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Pair<Charset, byte[]> charsetForWriting(@Nullable Project project,
|
||||
private static Pair.NonNull<Charset, byte[]> charsetForWriting(@Nullable Project project,
|
||||
@NotNull VirtualFile virtualFile,
|
||||
@NotNull String text,
|
||||
@Nullable Charset existing) {
|
||||
@NotNull Charset existing) {
|
||||
Charset specified = extractCharsetFromFileContent(project, virtualFile, text);
|
||||
Pair<Charset, byte[]> chosen = chooseMostlyHarmlessCharset(existing, specified, text);
|
||||
Pair.NonNull<Charset, byte[]> chosen = chooseMostlyHarmlessCharset(existing, specified, text);
|
||||
Charset charset = chosen.first;
|
||||
|
||||
// in case of "UTF-16", OutputStreamWriter sometimes adds BOM on it's own.
|
||||
@@ -287,7 +290,7 @@ public final class LoadTextUtil {
|
||||
byte[] bom = virtualFile.getBOM();
|
||||
Charset fromBom = bom == null ? null : CharsetToolkit.guessFromBOM(bom);
|
||||
if (fromBom != null && !fromBom.equals(charset)) {
|
||||
chosen = Pair.create(fromBom, toBytes(text, fromBom));
|
||||
chosen = Pair.createNonNull(fromBom, toBytes(text, fromBom));
|
||||
}
|
||||
return chosen;
|
||||
}
|
||||
@@ -303,19 +306,24 @@ public final class LoadTextUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Pair<Charset, byte[]> chooseMostlyHarmlessCharset(Charset existing, Charset specified, @NotNull String text) {
|
||||
public static Pair.NonNull<Charset, byte[]> chooseMostlyHarmlessCharset(@NotNull Charset existing, @NotNull Charset specified, @NotNull String text) {
|
||||
try {
|
||||
if (existing == null) return Pair.create(specified, toBytes(text, specified));
|
||||
if (specified == null || specified.equals(existing)) return Pair.create(specified, toBytes(text, existing));
|
||||
if (specified.equals(existing)) {
|
||||
return Pair.createNonNull(specified, toBytes(text, existing));
|
||||
}
|
||||
|
||||
byte[] out = isSupported(specified, text);
|
||||
if (out != null) return Pair.create(specified, out); //if explicitly specified encoding is safe, return it
|
||||
if (out != null) {
|
||||
return Pair.createNonNull(specified, out); //if explicitly specified encoding is safe, return it
|
||||
}
|
||||
out = isSupported(existing, text);
|
||||
if (out != null) return Pair.create(existing, out); //otherwise stick to the old encoding if it's ok
|
||||
return Pair.create(specified, toBytes(text, specified)); //if both are bad there is no difference
|
||||
if (out != null) {
|
||||
return Pair.createNonNull(existing, out); //otherwise stick to the old encoding if it's ok
|
||||
}
|
||||
return Pair.createNonNull(specified, toBytes(text, specified)); //if both are bad there is no difference
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
return Pair.create(Charset.defaultCharset(), toBytes(text, null)); //if both are bad and there is no hope, use the default charset
|
||||
return Pair.createNonNull(Charset.defaultCharset(), toBytes(text, null)); //if both are bad and there is no hope, use the default charset
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,18 +349,9 @@ public final class LoadTextUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Charset extractCharsetFromFileContent(@Nullable Project project, @NotNull VirtualFile virtualFile, @NotNull String text) {
|
||||
Charset charset = charsetFromContentOrNull(project, virtualFile, text);
|
||||
if (charset == null) charset = virtualFile.getCharset();
|
||||
return charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #charsetFromContentOrNull(com.intellij.openapi.project.Project, com.intellij.openapi.vfs.VirtualFile, CharSequence)}
|
||||
*/
|
||||
@Nullable("returns null if cannot determine from content")
|
||||
public static Charset charsetFromContentOrNull(@Nullable Project project, @NotNull VirtualFile virtualFile, @NotNull String text) {
|
||||
return CharsetUtil.extractCharsetFromFileContent(project, virtualFile, virtualFile.getFileType(), text);
|
||||
return ObjectUtils.notNull(charsetFromContentOrNull(project, virtualFile, text), virtualFile.getCharset());
|
||||
}
|
||||
|
||||
@Nullable("returns null if cannot determine from content")
|
||||
@@ -436,11 +435,12 @@ public final class LoadTextUtil {
|
||||
public static CharSequence getTextByBinaryPresentation(@NotNull byte[] bytes,
|
||||
@NotNull VirtualFile virtualFile,
|
||||
boolean saveDetectedSeparators,
|
||||
boolean saveBOM, @NotNull FileType fileType) {
|
||||
Pair<Charset, byte[]> pair = doDetectCharsetAndSetBOM(virtualFile, bytes, saveBOM, fileType);
|
||||
boolean saveBOM,
|
||||
@NotNull FileType fileType) {
|
||||
Pair.NonNull<Charset, byte[]> pair = doDetectCharsetAndSetBOM(virtualFile, bytes, saveBOM, fileType);
|
||||
Charset charset = pair.getFirst();
|
||||
byte[] bom = pair.getSecond();
|
||||
int offset = bom == null ? 0 : bom.length;
|
||||
int offset = bom.length;
|
||||
|
||||
Pair<CharSequence, String> result = convertBytes(bytes, charset, offset);
|
||||
if (saveDetectedSeparators) {
|
||||
@@ -476,26 +476,20 @@ public final class LoadTextUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static CharSequence getTextByBinaryPresentation(@NotNull byte[] bytes, Charset charset) {
|
||||
Pair<Charset, byte[]> pair = getBOMAndCharset(bytes, charset);
|
||||
public static CharSequence getTextByBinaryPresentation(@NotNull byte[] bytes, @NotNull Charset charset) {
|
||||
Pair.NonNull<Charset, byte[]> pair = getCharsetAndBOM(bytes, charset);
|
||||
byte[] bom = pair.getSecond();
|
||||
int offset = bom == null ? 0 : bom.length;
|
||||
int offset = bom.length;
|
||||
|
||||
final Pair<CharSequence, String> result = convertBytes(bytes, charset, offset);
|
||||
final Pair<CharSequence, String> result = convertBytes(bytes, pair.first, offset);
|
||||
return result.getFirst();
|
||||
}
|
||||
|
||||
// do not need to think about BOM here. it is processed outside
|
||||
@NotNull
|
||||
private static Pair<CharSequence, String> convertBytes(@NotNull byte[] bytes, Charset charset, final int startOffset) {
|
||||
private static Pair<CharSequence, String> convertBytes(@NotNull byte[] bytes, @NotNull Charset charset, final int startOffset) {
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes, startOffset, bytes.length - startOffset);
|
||||
|
||||
if (charset == null) {
|
||||
charset = CharsetToolkit.getDefaultSystemCharset();
|
||||
}
|
||||
if (charset == null) {
|
||||
charset = Charset.forName("ISO-8859-1");
|
||||
}
|
||||
CharBuffer charBuffer;
|
||||
try {
|
||||
charBuffer = charset.decode(byteBuffer);
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.openapi.progress.util;
|
||||
|
||||
import com.intellij.openapi.progress.StandardProgressIndicator;
|
||||
|
||||
public class StandardProgressIndicatorBase extends AbstractProgressIndicatorBase implements StandardProgressIndicator {
|
||||
@Override
|
||||
public final void cancel() {
|
||||
super.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isCanceled() {
|
||||
return super.isCanceled();
|
||||
}
|
||||
}
|
||||
+8
-18
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator;
|
||||
import com.intellij.diagnostic.ThreadDumper;
|
||||
import com.intellij.ide.startup.impl.StartupManagerImpl;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationAdapter;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
@@ -27,9 +25,8 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.util.ProgressIndicatorBase;
|
||||
import com.intellij.openapi.progress.util.StandardProgressIndicatorBase;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.FileViewProvider;
|
||||
@@ -175,7 +172,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
|
||||
private void doQueue(@NotNull Project project, @NotNull Document document, @NotNull Object reason) {
|
||||
synchronized (documentsToCommit) {
|
||||
ProgressIndicator indicator = new DaemonProgressIndicator();
|
||||
ProgressIndicator indicator = createProgressIndicator();
|
||||
CommitTask newTask = new CommitTask(document, project, indicator, reason);
|
||||
|
||||
markRemovedFromDocsToCommit(newTask);
|
||||
@@ -211,7 +208,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
}
|
||||
if (task != null) {
|
||||
boolean stillUncommitted = !task.project.isDisposed() &&
|
||||
((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(task.project)).isInUncommittedSet(task.document);
|
||||
((PsiDocumentManagerBase)PsiDocumentManager.getInstance(task.project)).isInUncommittedSet(task.document);
|
||||
if (stillUncommitted) {
|
||||
s += "; Uncommitted: " + task.document;
|
||||
}
|
||||
@@ -325,7 +322,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
|
||||
log("Pulled", task, false, indicator);
|
||||
|
||||
if (project.isDisposed() || !((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project)).isInUncommittedSet(document)) {
|
||||
if (project.isDisposed() || !((PsiDocumentManagerBase)PsiDocumentManager.getInstance(project)).isInUncommittedSet(document)) {
|
||||
log("Abandon and proceed to next",task, false);
|
||||
return;
|
||||
}
|
||||
@@ -394,13 +391,6 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
|
||||
if (!project.isInitialized() && !project.isDefault()) {
|
||||
@NonNls String s = project + "; Disposed: "+project.isDisposed()+"; Open: "+project.isOpen();
|
||||
s += "; SA Passed: ";
|
||||
try {
|
||||
s += ((StartupManagerImpl)StartupManager.getInstance(project)).startupActivityPassed();
|
||||
}
|
||||
catch (Exception e) {
|
||||
s += e;
|
||||
}
|
||||
try {
|
||||
Disposer.dispose(project);
|
||||
}
|
||||
@@ -433,7 +423,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
@NotNull
|
||||
@Override
|
||||
protected ProgressIndicator createProgressIndicator() {
|
||||
return new ProgressIndicatorBase();
|
||||
return new StandardProgressIndicatorBase();
|
||||
}
|
||||
|
||||
private void startNewTask(@Nullable CommitTask task, @NotNull Object reason) {
|
||||
@@ -459,7 +449,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
myApplication.assertReadAccessAllowed();
|
||||
if (project.isDisposed()) return;
|
||||
|
||||
final PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project);
|
||||
final PsiDocumentManagerBase documentManager = (PsiDocumentManagerBase)PsiDocumentManager.getInstance(project);
|
||||
if (documentManager.isCommitted(document)) return;
|
||||
|
||||
FileViewProvider viewProvider = documentManager.getCachedViewProvider(document);
|
||||
@@ -525,7 +515,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
}
|
||||
}
|
||||
|
||||
PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project);
|
||||
PsiDocumentManagerBase documentManager = (PsiDocumentManagerBase)PsiDocumentManager.getInstance(project);
|
||||
|
||||
log("Executing later finishCommit", task, false);
|
||||
boolean success = documentManager.finishCommit(document, finishProcessors, synchronously, task.reason);
|
||||
@@ -546,7 +536,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Processor<Document> handleCommitWithoutPsi(@NotNull final PsiDocumentManagerImpl documentManager,
|
||||
private Processor<Document> handleCommitWithoutPsi(@NotNull final PsiDocumentManagerBase documentManager,
|
||||
@NotNull Document document,
|
||||
@NotNull final CommitTask task,
|
||||
final boolean synchronously) {
|
||||
@@ -285,18 +285,16 @@ public class BlockSupportImpl extends BlockSupport {
|
||||
@NotNull final DiffTreeChangeBuilder<ASTNode, T> builder,
|
||||
@NotNull final ShallowNodeComparator<ASTNode, T> comparator,
|
||||
@NotNull final FlyweightCapableTreeStructure<T> newTreeStructure,
|
||||
final ProgressIndicator indicator) {
|
||||
@NotNull ProgressIndicator indicator) {
|
||||
TreeUtil.ensureParsedRecursivelyCheckingProgress(oldRoot, indicator);
|
||||
DiffTree.diff(createInterruptibleASTStructure(oldRoot, indicator), newTreeStructure, comparator, builder);
|
||||
}
|
||||
|
||||
private static ASTStructure createInterruptibleASTStructure(@NotNull final ASTNode oldRoot, @Nullable final ProgressIndicator indicator) {
|
||||
private static ASTStructure createInterruptibleASTStructure(@NotNull final ASTNode oldRoot, @NotNull final ProgressIndicator indicator) {
|
||||
return new ASTStructure(oldRoot) {
|
||||
@Override
|
||||
public int getChildren(@NotNull ASTNode astNode, @NotNull Ref<ASTNode[]> into) {
|
||||
if (indicator != null) {
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
indicator.checkCanceled();
|
||||
return super.getChildren(astNode, into);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,13 +57,11 @@ public class TreeUtil {
|
||||
public static void ensureParsedRecursively(@NotNull ASTNode node) {
|
||||
((TreeElement)node).acceptTree(new RecursiveTreeElementWalkingVisitor() { });
|
||||
}
|
||||
public static void ensureParsedRecursivelyCheckingProgress(@NotNull ASTNode node, final ProgressIndicator indicator) {
|
||||
public static void ensureParsedRecursivelyCheckingProgress(@NotNull ASTNode node, @NotNull final ProgressIndicator indicator) {
|
||||
((TreeElement)node).acceptTree(new RecursiveTreeElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitLeaf(LeafElement leaf) {
|
||||
if (indicator != null) {
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.util.ThreadLocalCachedByteArray;
|
||||
import com.intellij.util.io.DataInputOutputUtil;
|
||||
import org.iq80.snappy.CorruptionException;
|
||||
import org.iq80.snappy.Snappy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -33,7 +34,7 @@ public class CompressionUtil {
|
||||
private static final int COMPRESSION_THRESHOLD = 64;
|
||||
private static final ThreadLocalCachedByteArray spareBufferLocal = new ThreadLocalCachedByteArray();
|
||||
|
||||
public static int writeCompressed(DataOutput out, byte[] bytes, int length) throws IOException {
|
||||
public static int writeCompressed(@NotNull DataOutput out, @NotNull byte[] bytes, int length) throws IOException {
|
||||
if (length > COMPRESSION_THRESHOLD) {
|
||||
final byte[] compressedOutputBuffer = spareBufferLocal.getBuffer(Snappy.maxCompressedLength(length));
|
||||
|
||||
@@ -41,20 +42,23 @@ public class CompressionUtil {
|
||||
DataInputOutputUtil.writeINT(out, -compressedSize);
|
||||
out.write(compressedOutputBuffer, 0, compressedSize);
|
||||
return compressedSize;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
DataInputOutputUtil.writeINT(out, length);
|
||||
out.write(bytes, 0, length);
|
||||
return length;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] readCompressed(DataInput in) throws IOException {
|
||||
@NotNull
|
||||
public static byte[] readCompressed(@NotNull DataInput in) throws IOException {
|
||||
int size = DataInputOutputUtil.readINT(in);
|
||||
if (size < 0) {
|
||||
byte[] bytes = spareBufferLocal.getBuffer(-size);
|
||||
in.readFully(bytes, 0, -size);
|
||||
return Snappy.uncompress(bytes, 0, -size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
byte[] bytes = new byte[size];
|
||||
in.readFully(bytes);
|
||||
return bytes;
|
||||
@@ -63,7 +67,8 @@ public class CompressionUtil {
|
||||
|
||||
private static final int STRING_COMPRESSION_THRESHOLD = 1024;
|
||||
|
||||
public static CharSequence uncompressCharSequence(Object string, Charset charset) {
|
||||
@NotNull
|
||||
public static CharSequence uncompressCharSequence(@NotNull Object string, @NotNull Charset charset) {
|
||||
if (string instanceof CharSequence) return (CharSequence)string;
|
||||
byte[] b = (byte[])string;
|
||||
try {
|
||||
@@ -71,12 +76,14 @@ public class CompressionUtil {
|
||||
byte[] bytes = spareBufferLocal.getBuffer(uncompressedLength);
|
||||
int bytesLength = Snappy.uncompress(b, 0, b.length, bytes, 0);
|
||||
return new String(bytes, 0, bytesLength, charset);
|
||||
} catch (CorruptionException ex) {
|
||||
}
|
||||
catch (CorruptionException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object compressCharSequence(CharSequence string, Charset charset) {
|
||||
@NotNull
|
||||
public static Object compressCharSequence(@NotNull CharSequence string, @NotNull Charset charset) {
|
||||
if (string.length() < STRING_COMPRESSION_THRESHOLD) {
|
||||
if (string instanceof CharBuffer && ((CharBuffer)string).capacity() > STRING_COMPRESSION_THRESHOLD) {
|
||||
string = string.toString(); // shrink to size
|
||||
@@ -85,7 +92,8 @@ public class CompressionUtil {
|
||||
}
|
||||
try {
|
||||
return Snappy.compress(string.toString().getBytes(charset));
|
||||
} catch (CorruptionException ex) {
|
||||
}
|
||||
catch (CorruptionException ex) {
|
||||
ex.printStackTrace();
|
||||
return string;
|
||||
}
|
||||
|
||||
+6
-7
@@ -38,10 +38,7 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.ByteSequence;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
|
||||
import com.intellij.testFramework.*;
|
||||
@@ -55,7 +52,9 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
@@ -490,10 +489,10 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase {
|
||||
@Override
|
||||
protected void run(@NotNull Result<VirtualFile> result) throws Throwable {
|
||||
if (advanceStamps) {
|
||||
file.setBinaryContent(content.getBytes("UTF-8"), -1, file.getTimeStamp() + 4000);
|
||||
file.setBinaryContent(content.getBytes(CharsetToolkit.UTF8_CHARSET), -1, file.getTimeStamp() + 4000);
|
||||
}
|
||||
else {
|
||||
file.setBinaryContent(content.getBytes("UTF-8"), file.getModificationStamp(), file.getTimeStamp());
|
||||
file.setBinaryContent(content.getBytes(CharsetToolkit.UTF8_CHARSET), file.getModificationStamp(), file.getTimeStamp());
|
||||
}
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtilRt;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
@@ -271,11 +270,8 @@ public class JdkUtil {
|
||||
if (encoding == null) {
|
||||
Charset charset = javaParameters.getCharset();
|
||||
if (charset == null) charset = EncodingManager.getInstance().getDefaultCharset();
|
||||
if (charset == null) charset = CharsetToolkit.getDefaultSystemCharset();
|
||||
if (charset != null) {
|
||||
commandLine.addParameter("-Dfile.encoding=" + charset.name());
|
||||
commandLine.withCharset(charset);
|
||||
}
|
||||
commandLine.addParameter("-Dfile.encoding=" + charset.name());
|
||||
commandLine.withCharset(charset);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -361,7 +361,7 @@ public abstract class AbstractExternalFilter {
|
||||
while (read != null && !startSection.matcher(StringUtil.toUpperCase(read)).find());
|
||||
|
||||
if (input instanceof MyReader && contentEncoding != null) {
|
||||
if (!contentEncoding.equalsIgnoreCase("UTF-8") &&
|
||||
if (!contentEncoding.equalsIgnoreCase(CharsetToolkit.UTF8) &&
|
||||
!contentEncoding.equals(((MyReader)input).getEncoding()))
|
||||
{ //restart page parsing with correct encoding
|
||||
Reader stream;
|
||||
|
||||
+3
-2
@@ -54,6 +54,7 @@ import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
@@ -185,7 +186,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
|
||||
new File(outputPath).mkdirs();
|
||||
final File file = new File(outputPath, toolName + ext);
|
||||
inspectionsResults.add(file);
|
||||
FileUtil.writeToFile(file, ("</" + InspectionsBundle.message("inspection.problems") + ">").getBytes("UTF-8"), true);
|
||||
FileUtil.writeToFile(file, ("</" + InspectionsBundle.message("inspection.problems") + ">").getBytes(CharsetToolkit.UTF8_CHARSET), true);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
@@ -221,7 +222,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
|
||||
final File file = new File(outputPath, toolName + ext);
|
||||
inspectionsResults.add(file);
|
||||
|
||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
|
||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), CharsetToolkit.UTF8_CHARSET);
|
||||
try {
|
||||
JDOMUtil.writeDocument(doc, writer, "\n");
|
||||
}
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManagerImpl;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -287,7 +288,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
pathMacroManager.collapsePaths(element);
|
||||
JDOMUtil.writeElement(element, writer, "\n");
|
||||
}
|
||||
printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName, true), "UTF-8")));
|
||||
printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName, true), CharsetToolkit.UTF8_CHARSET)));
|
||||
printWriter.append("\n");
|
||||
printWriter.append(writer.toString());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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,9 +22,7 @@ import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -76,7 +74,7 @@ public class ConsoleViewRunningState extends ConsoleState {
|
||||
charset = ((OSProcessHandler)processHandler).getCharset();
|
||||
}
|
||||
if (charset == null) {
|
||||
charset = ObjectUtils.notNull(EncodingManager.getInstance().getDefaultCharset(), CharsetToolkit.UTF8_CHARSET);
|
||||
charset = EncodingManager.getInstance().getDefaultCharset();
|
||||
}
|
||||
return new OutputStreamWriter(processInput, charset);
|
||||
}
|
||||
|
||||
@@ -15,13 +15,10 @@
|
||||
*/
|
||||
package com.intellij.ide.fileTemplates.impl;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -247,7 +244,7 @@ class FTManager {
|
||||
else {
|
||||
// both customized content on disk and corresponding template are present
|
||||
try {
|
||||
final String diskText = StringUtil.convertLineSeparators(FileUtil.loadFile(customizedTemplateFile, CONTENT_ENCODING));
|
||||
final String diskText = StringUtil.convertLineSeparators(FileUtil.loadFile(customizedTemplateFile, CharsetToolkit.UTF8_CHARSET));
|
||||
final String templateText = templateToSave.getText();
|
||||
if (!diskText.equals(templateText)) {
|
||||
// save only if texts differ to avoid unnecessary file touching
|
||||
@@ -278,16 +275,7 @@ class FTManager {
|
||||
FileUtil.delete(templateFile);
|
||||
fileOutputStream = new FileOutputStream(templateFile);
|
||||
}
|
||||
OutputStreamWriter outputStreamWriter;
|
||||
try{
|
||||
outputStreamWriter = new OutputStreamWriter(fileOutputStream, CONTENT_ENCODING);
|
||||
}
|
||||
catch (UnsupportedEncodingException e){
|
||||
Messages.showMessageDialog(IdeBundle.message("error.unable.to.save.file.template.using.encoding", template.getName(),
|
||||
CONTENT_ENCODING),
|
||||
CommonBundle.getErrorTitle(), Messages.getErrorIcon());
|
||||
outputStreamWriter = new OutputStreamWriter(fileOutputStream);
|
||||
}
|
||||
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, CharsetToolkit.UTF8_CHARSET);
|
||||
String content = template.getText();
|
||||
|
||||
if (!lineSeparator.equals("\n")){
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.extensions.PluginDescriptor;
|
||||
import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -235,7 +236,7 @@ public class FileTemplatesLoader {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final String text = FileUtil.loadFile(file, FTManager.CONTENT_ENCODING);
|
||||
final String text = FileUtil.loadFile(file, CharsetToolkit.UTF8_CHARSET);
|
||||
manager.addTemplate(templateQName, extension).setText(text);
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
+22
-24
@@ -28,7 +28,7 @@ import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
@@ -52,8 +52,8 @@ public class FileEncodingConfigurable implements SearchableConfigurable, Optiona
|
||||
private JCheckBox myTransparentNativeToAsciiCheckBox;
|
||||
private JPanel myPropertiesFilesEncodingCombo;
|
||||
private final Ref<Charset> mySelectedCharsetForPropertiesFiles = new Ref<Charset>();
|
||||
private final Ref<Charset> mySelectedIdeCharset = new Ref<Charset>();
|
||||
private final Ref<Charset> mySelectedProjectCharset = new Ref<Charset>();
|
||||
private final Ref<Charset> mySelectedIdeCharset = new Ref<Charset>(); // IDE encoding or null if "System Default"
|
||||
private final Ref<Charset> mySelectedProjectCharset = new Ref<Charset>(); // Project encoding or null if "System Default"
|
||||
private JLabel myTitleLabel;
|
||||
private JPanel myIdeEncodingsListCombo;
|
||||
private JPanel myProjectEncodingListCombo;
|
||||
@@ -90,13 +90,14 @@ public class FileEncodingConfigurable implements SearchableConfigurable, Optiona
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static ChooseFileEncodingAction installChooseEncodingCombo(@NotNull JPanel parentPanel, @NotNull final Ref<Charset> selected) {
|
||||
ChooseFileEncodingAction myAction = new ChooseFileEncodingAction(null) {
|
||||
@Override
|
||||
public void update(final AnActionEvent e) {
|
||||
getTemplatePresentation().setEnabled(true);
|
||||
Charset charset = selected.get();
|
||||
getTemplatePresentation().setText(charset == null ? IdeBundle.message("encoding.name.system.default") : charset.displayName());
|
||||
getTemplatePresentation().setText(charset == null ? IdeBundle.message("encoding.name.system.default", CharsetToolkit.getDefaultSystemCharset().displayName()) : charset.displayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,33 +151,30 @@ public class FileEncodingConfigurable implements SearchableConfigurable, Optiona
|
||||
}
|
||||
|
||||
private boolean isIdeEncodingModified() {
|
||||
Charset charset = mySelectedIdeCharset.get();
|
||||
if (null == charset) {
|
||||
return !StringUtil.isEmpty(EncodingManager.getInstance().getDefaultCharsetName());
|
||||
}
|
||||
|
||||
return !Comparing.equal(charset, EncodingManager.getInstance().getDefaultCharset());
|
||||
String charsetName = getSelectedCharsetName(mySelectedIdeCharset);
|
||||
return !charsetName.equals(EncodingManager.getInstance().getDefaultCharsetName());
|
||||
}
|
||||
private boolean isProjectEncodingModified() {
|
||||
Charset charset = mySelectedProjectCharset.get();
|
||||
return !Comparing.equal(charset, EncodingProjectManager.getInstance(myProject).getEncoding(null, false));
|
||||
String charsetName = getSelectedCharsetName(mySelectedProjectCharset);
|
||||
return !charsetName.equals(EncodingProjectManager.getInstance(myProject).getDefaultCharsetName());
|
||||
}
|
||||
|
||||
@NotNull // charset name or empty for System Default
|
||||
private static String getSelectedCharsetName(@NotNull Ref<Charset> selectedCharset) {
|
||||
Charset charset = selectedCharset.get();
|
||||
return charset == null ? "" : charset.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
Charset projectCharset = mySelectedProjectCharset.get();
|
||||
String projectCharsetName = getSelectedCharsetName(mySelectedProjectCharset);
|
||||
|
||||
Map<VirtualFile,Charset> result = myTreeView.getValues();
|
||||
if (projectCharset == null) {
|
||||
result.remove(null);
|
||||
}
|
||||
else {
|
||||
result.put(null, projectCharset);
|
||||
}
|
||||
EncodingProjectManager encodingManager = EncodingProjectManager.getInstance(myProject);
|
||||
encodingManager.setMapping(result);
|
||||
encodingManager.setDefaultCharsetForPropertiesFiles(null, mySelectedCharsetForPropertiesFiles.get());
|
||||
encodingManager.setNative2AsciiForPropertiesFiles(null, myTransparentNativeToAsciiCheckBox.isSelected());
|
||||
EncodingProjectManager encodingProjectManager = EncodingProjectManager.getInstance(myProject);
|
||||
encodingProjectManager.setMapping(result);
|
||||
encodingProjectManager.setDefaultCharsetName(projectCharsetName);
|
||||
encodingProjectManager.setDefaultCharsetForPropertiesFiles(null, mySelectedCharsetForPropertiesFiles.get());
|
||||
encodingProjectManager.setNative2AsciiForPropertiesFiles(null, myTransparentNativeToAsciiCheckBox.isSelected());
|
||||
|
||||
Charset ideCharset = mySelectedIdeCharset.get();
|
||||
EncodingManager.getInstance().setDefaultCharsetName(ideCharset == null ? "" : ideCharset.name());
|
||||
@@ -190,7 +188,7 @@ public class FileEncodingConfigurable implements SearchableConfigurable, Optiona
|
||||
mySelectedCharsetForPropertiesFiles.set(encodingManager.getDefaultCharsetForPropertiesFiles(null));
|
||||
|
||||
mySelectedIdeCharset.set(EncodingManager.getInstance().getDefaultCharsetName().isEmpty() ? null : EncodingManager.getInstance().getDefaultCharset());
|
||||
mySelectedProjectCharset.set(EncodingProjectManager.getInstance(myProject).getEncoding(null, false));
|
||||
mySelectedProjectCharset.set(EncodingProjectManager.getInstance(myProject).getDefaultCharsetName().isEmpty() ? null : EncodingProjectManager.getInstance(myProject).getDefaultCharset());
|
||||
myPropertiesEncodingAction.update(null);
|
||||
myIdeEncodingAction.update(null);
|
||||
myProjectEncodingAction.update(null);
|
||||
|
||||
@@ -25,13 +25,13 @@ import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileElement;
|
||||
import com.intellij.openapi.fileChooser.ex.FileChooserKeys;
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.ui.playback.PlaybackContext;
|
||||
import com.intellij.openapi.ui.playback.PlaybackRunner;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingRegistry;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
@@ -275,14 +275,9 @@ public class PlaybackDebugger implements UiDebuggerExtension, PlaybackRunner.Sta
|
||||
}
|
||||
|
||||
private void loadFrom(@NotNull VirtualFile file) {
|
||||
try {
|
||||
final String text = CharsetToolkit.bytesToString(file.contentsToByteArray(), EncodingRegistry.getInstance().getDefaultCharset());
|
||||
fillDocument(text);
|
||||
myChanged = false;
|
||||
}
|
||||
catch (IOException e) {
|
||||
Messages.showErrorDialog(e.getMessage(), "Cannot load file");
|
||||
}
|
||||
final String text = LoadTextUtil.loadText(file).toString();
|
||||
fillDocument(text);
|
||||
myChanged = false;
|
||||
}
|
||||
|
||||
private File getScriptsFile() {
|
||||
|
||||
+5
-9
@@ -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.
|
||||
@@ -18,7 +18,6 @@ package com.intellij.execution.configurations;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
|
||||
import com.intellij.util.EnvironmentUtil;
|
||||
@@ -138,15 +137,12 @@ public class EncodingEnvironmentUtil {
|
||||
|
||||
@NotNull
|
||||
private static Charset getCharset(@Nullable Project project) {
|
||||
Charset charset = null;
|
||||
if (project != null) {
|
||||
charset = EncodingProjectManager.getInstance(project).getDefaultCharset();
|
||||
}
|
||||
if (charset == null) {
|
||||
Charset charset;
|
||||
if (project == null) {
|
||||
charset = EncodingManager.getInstance().getDefaultCharset();
|
||||
}
|
||||
if (charset == null) {
|
||||
charset = CharsetToolkit.UTF8_CHARSET;
|
||||
else {
|
||||
charset = EncodingProjectManager.getInstance(project).getDefaultCharset();
|
||||
}
|
||||
return charset;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.
|
||||
@@ -80,6 +80,7 @@ public abstract class DiffElement<T> /*implements Disposable */{
|
||||
@Nullable
|
||||
public abstract byte[] getContent() throws IOException;
|
||||
|
||||
@NotNull
|
||||
public Charset getCharset() {
|
||||
return EncodingManager.getInstance().getDefaultCharset();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -25,8 +25,9 @@ import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingRegistry;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -45,7 +46,7 @@ public class BinaryContent extends DiffContent {
|
||||
private final byte[] myBytes;
|
||||
private final Charset myCharset;
|
||||
private Document myDocument = null;
|
||||
private String myFilePath;
|
||||
private final String myFilePath;
|
||||
|
||||
/**
|
||||
* @param charset use to convert bytes to String. null means bytes can't be converted to text. Has no sense if fileType.isBinary()
|
||||
@@ -88,12 +89,8 @@ public class BinaryContent extends DiffContent {
|
||||
|
||||
String text = null;
|
||||
try {
|
||||
if (myCharset == null) {
|
||||
text = CharsetToolkit.bytesToString(myBytes, EncodingRegistry.getInstance().getDefaultCharset());
|
||||
}
|
||||
else {
|
||||
text = CharsetToolkit.bytesToString(myBytes, myCharset);
|
||||
}
|
||||
Charset charset = ObjectUtils.notNull(myCharset, EncodingProjectManager.getInstance(myProject).getDefaultCharset());
|
||||
text = CharsetToolkit.bytesToString(myBytes, charset);
|
||||
}
|
||||
catch (IllegalCharsetNameException e) {
|
||||
}
|
||||
|
||||
@@ -250,6 +250,19 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArrowButtonListener createArrowButtonListener() {
|
||||
return new ArrowButtonListener() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent event) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected boolean isMacOverlayScrollbar() {
|
||||
return myMacScrollerStyle == NSScrollerHelper.Style.Overlay && isMacOverlayScrollbarSupported();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -25,10 +25,8 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -138,7 +136,7 @@ public final class ScriptRunnerUtil {
|
||||
LOG.debug("Command line env: ", commandLine.getEnvironment());
|
||||
|
||||
if (charset == null) {
|
||||
charset = ObjectUtils.notNull(EncodingManager.getInstance().getDefaultCharset(), CharsetToolkit.UTF8_CHARSET);
|
||||
charset = EncodingManager.getInstance().getDefaultCharset();
|
||||
}
|
||||
final OSProcessHandler processHandler = new ColoredProcessHandler(commandLine.createProcess(),
|
||||
commandLine.getCommandLineString(),
|
||||
|
||||
@@ -656,12 +656,7 @@ public class IdeEventQueue extends EventQueue {
|
||||
try {
|
||||
Object owner = getNativeFocusOwner.invoke(mgr);
|
||||
if (owner instanceof Component) {
|
||||
Component nativeFocusOwner = (Component)owner;
|
||||
if (nativeFocusOwner instanceof Window) {
|
||||
showingWindow = (Window)nativeFocusOwner;
|
||||
} else {
|
||||
showingWindow = SwingUtilities.getWindowAncestor(nativeFocusOwner);
|
||||
}
|
||||
showingWindow = UIUtil.getWindow((Component)owner);
|
||||
}
|
||||
}
|
||||
catch (Exception e1) {
|
||||
@@ -996,7 +991,7 @@ public class IdeEventQueue extends EventQueue {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final Window window = component instanceof Window ? (Window)component : SwingUtilities.windowForComponent(component);
|
||||
final Window window = UIUtil.getWindow(component);
|
||||
if (window == null || !window.isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
+4
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package com.intellij.ide.passwordSafe.impl.providers;
|
||||
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
@@ -224,12 +224,7 @@ public class EncryptionUtil {
|
||||
if (len < 0 || len > plain.length - 4) {
|
||||
throw new IllegalStateException("Unmatched password is used");
|
||||
}
|
||||
try {
|
||||
return new String(plain, 4, len, "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalStateException("UTF-8 is not available", e);
|
||||
}
|
||||
return new String(plain, 4, len, CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,12 +234,7 @@ public class EncryptionUtil {
|
||||
* @return the UTF-8 encoded string
|
||||
*/
|
||||
public static byte[] getUTF8Bytes(String string) {
|
||||
try {
|
||||
return string.getBytes("UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalStateException("UTF-8 encoding is not available", e);
|
||||
}
|
||||
return string.getBytes(CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-7
@@ -31,13 +31,13 @@ import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -338,12 +338,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
|
||||
private static String decryptPassword(byte[] pw) throws MasterPasswordUnavailableException {
|
||||
if (!SystemInfo.isWindows) throw new AssertionError("Windows OS expected");
|
||||
|
||||
try {
|
||||
return new String(WindowsCryptUtils.unprotect(pw), "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalStateException("UTF-8 not available", e);
|
||||
}
|
||||
return new String(WindowsCryptUtils.unprotect(pw), CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
|
||||
public boolean isPasswordEncrypted() {
|
||||
|
||||
+4
-13
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
import javax.swing.event.MouseInputListener;
|
||||
@@ -109,12 +111,7 @@ public class DarculaRootPaneUI extends BasicRootPaneUI {
|
||||
|
||||
|
||||
private void installWindowListeners(JRootPane root, Component parent) {
|
||||
if (parent instanceof Window) {
|
||||
myWindow = (Window)parent;
|
||||
}
|
||||
else {
|
||||
myWindow = SwingUtilities.getWindowAncestor(parent);
|
||||
}
|
||||
myWindow = UIUtil.getWindow(parent);
|
||||
|
||||
if (myWindow != null) {
|
||||
if (myMouseInputListener == null) {
|
||||
@@ -177,13 +174,7 @@ public class DarculaRootPaneUI extends BasicRootPaneUI {
|
||||
});
|
||||
}
|
||||
|
||||
Window currWindow;
|
||||
if (parent instanceof Window) {
|
||||
currWindow = (Window)parent;
|
||||
}
|
||||
else {
|
||||
currWindow = SwingUtilities.getWindowAncestor(parent);
|
||||
}
|
||||
Window currWindow = UIUtil.getWindow(parent);
|
||||
if (myWindowListener != null) {
|
||||
myCurrentWindow
|
||||
.removeWindowListener(myWindowListener);
|
||||
|
||||
@@ -90,9 +90,7 @@ public class IdeaApplication {
|
||||
boolean isUnitTest = Boolean.getBoolean(IDEA_IS_UNIT_TEST);
|
||||
|
||||
boolean headless = Main.isHeadless();
|
||||
if (!headless) {
|
||||
patchSystem();
|
||||
}
|
||||
patchSystem(headless);
|
||||
|
||||
if (Main.isCommandLine()) {
|
||||
if (CommandLineApplication.ourInstance == null) {
|
||||
@@ -126,10 +124,12 @@ public class IdeaApplication {
|
||||
myStarter.premain(args);
|
||||
}
|
||||
|
||||
private static void patchSystem() {
|
||||
private static void patchSystem(boolean headless) {
|
||||
System.setProperty("sun.awt.noerasebackground", "true");
|
||||
|
||||
IdeEventQueue.getInstance(); // replace system event queue
|
||||
|
||||
if (headless) return;
|
||||
|
||||
if (Patches.SUN_BUG_ID_6209673) {
|
||||
RepaintManager.setCurrentManager(new IdeRepaintManager());
|
||||
|
||||
+3
-2
@@ -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) {
|
||||
@@ -671,7 +672,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
@Override
|
||||
@NotNull
|
||||
public ModalityState getModalityStateForComponent(@NotNull Component c) {
|
||||
Window window = c instanceof Window ? (Window)c : SwingUtilities.windowForComponent(c);
|
||||
Window window = UIUtil.getWindow(c);
|
||||
if (window == null) return getNoneModalityState(); //?
|
||||
return LaterInvocator.modalityStateForWindow(window);
|
||||
}
|
||||
|
||||
+18
-20
@@ -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,29 +18,26 @@ package com.intellij.openapi.command.impl;
|
||||
import com.intellij.openapi.command.undo.BasicUndoableAction;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.editor.ex.DocumentEx;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.vcs.FileStatusManager;
|
||||
import com.intellij.openapi.vcs.impl.FileStatusManagerImpl;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.util.CompressionUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import static com.intellij.util.CompressionUtil.compressCharSequence;
|
||||
import static com.intellij.util.CompressionUtil.uncompressCharSequence;
|
||||
|
||||
public class EditorChangeAction extends BasicUndoableAction {
|
||||
private final int myOffset;
|
||||
private final Object myOldString;
|
||||
private final Object myNewString;
|
||||
private final long myOldTimeStamp;
|
||||
private final long myNewTimeStamp;
|
||||
@NotNull private final Charset myCharset;
|
||||
@NotNull private static final Charset myCharset= CharsetToolkit.UTF8_CHARSET;
|
||||
|
||||
public EditorChangeAction(DocumentEvent e) {
|
||||
this((DocumentEx)e.getDocument(), e.getOffset(), e.getOldFragment(), e.getNewFragment(), e.getOldTimeStamp());
|
||||
@@ -48,23 +45,18 @@ public class EditorChangeAction extends BasicUndoableAction {
|
||||
|
||||
public EditorChangeAction(@NotNull DocumentEx document,
|
||||
int offset,
|
||||
CharSequence oldString,
|
||||
CharSequence newString,
|
||||
@NotNull CharSequence oldString,
|
||||
@NotNull CharSequence newString,
|
||||
long oldTimeStamp) {
|
||||
super(document);
|
||||
|
||||
Charset charset = EncodingManager.getInstance().getEncoding(FileDocumentManager.getInstance().getFile(document), true);
|
||||
if (charset == null) charset = EncodingManager.getInstance().getDefaultCharset();
|
||||
if (charset == null) charset = Charset.defaultCharset();
|
||||
myCharset = charset;
|
||||
|
||||
myOffset = offset;
|
||||
myOldString = oldString == null ? "" : compressCharSequence(oldString, myCharset);
|
||||
myNewString = newString == null ? "" : compressCharSequence(newString, myCharset);
|
||||
myOldString = CompressionUtil.compressCharSequence(oldString, myCharset);
|
||||
myNewString = CompressionUtil.compressCharSequence(newString, myCharset);
|
||||
myOldTimeStamp = oldTimeStamp;
|
||||
myNewTimeStamp = document.getModificationStamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
DocumentUndoProvider.startDocumentUndo(getDocument());
|
||||
try {
|
||||
@@ -79,13 +71,18 @@ public class EditorChangeAction extends BasicUndoableAction {
|
||||
}
|
||||
|
||||
public void performUndo() {
|
||||
exchangeStrings(uncompressCharSequence(myNewString, myCharset), uncompressCharSequence(myOldString, myCharset));
|
||||
CharSequence oldString = CompressionUtil.uncompressCharSequence(myOldString, myCharset);
|
||||
CharSequence newString = CompressionUtil.uncompressCharSequence(myNewString, myCharset);
|
||||
exchangeStrings(newString, oldString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redo() {
|
||||
DocumentUndoProvider.startDocumentUndo(getDocument());
|
||||
try {
|
||||
exchangeStrings(uncompressCharSequence(myOldString, myCharset), uncompressCharSequence(myNewString, myCharset));
|
||||
CharSequence oldString = CompressionUtil.uncompressCharSequence(myOldString, myCharset);
|
||||
CharSequence newString = CompressionUtil.uncompressCharSequence(myNewString, myCharset);
|
||||
exchangeStrings(oldString, newString);
|
||||
}
|
||||
finally {
|
||||
DocumentUndoProvider.finishDocumentUndo(getDocument());
|
||||
@@ -94,7 +91,7 @@ public class EditorChangeAction extends BasicUndoableAction {
|
||||
refreshFileStatus();
|
||||
}
|
||||
|
||||
private void exchangeStrings(CharSequence newString, CharSequence oldString) {
|
||||
private void exchangeStrings(@NotNull CharSequence newString, @NotNull CharSequence oldString) {
|
||||
DocumentEx d = getDocument();
|
||||
|
||||
if (newString.length() > 0 && oldString.length() == 0) {
|
||||
@@ -123,6 +120,7 @@ public class EditorChangeAction extends BasicUndoableAction {
|
||||
return (DocumentEx)getAffectedDocuments()[0].getDocument();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNls
|
||||
public String toString() {
|
||||
return "editor change: '" + myOldString + "' to '" + myNewString + "'" + " at: " + myOffset;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -281,7 +281,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
final VirtualFile nameFile = ideaDir.findChild(ProjectImpl.NAME_FILE);
|
||||
if (nameFile != null && nameFile.isValid()) {
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(nameFile.getInputStream(), "UTF-8"));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(nameFile.getInputStream(), CharsetToolkit.UTF8_CHARSET));
|
||||
try {
|
||||
final String name = in.readLine();
|
||||
if (name != null && name.length() > 0) {
|
||||
|
||||
@@ -489,6 +489,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
myEditorComponent = new EditorComponentImpl(this);
|
||||
myScrollPane = new MyScrollPane();
|
||||
myVerticalScrollBar = (MyScrollBar)myScrollPane.getVerticalScrollBar();
|
||||
myVerticalScrollBar.setOpaque(false);
|
||||
myPanel = new JPanel();
|
||||
|
||||
UIUtil.putClientProperty(
|
||||
@@ -4852,6 +4853,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
public void setUI(ScrollBarUI ui) {
|
||||
if (myPersistentUI == null) myPersistentUI = ui;
|
||||
super.setUI(myPersistentUI);
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -472,6 +472,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
private class ErrorStripeButton extends JButton {
|
||||
private ErrorStripeButton() {
|
||||
setFocusable(false);
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-6
@@ -249,12 +249,7 @@ public final class IdeKeyEventDispatcher implements Disposable {
|
||||
* @throws IllegalArgumentException if <code>component</code> is <code>null</code>.
|
||||
*/
|
||||
public static boolean isModalContext(@NotNull Component component) {
|
||||
Window window;
|
||||
if (component instanceof Window) {
|
||||
window = (Window)component;
|
||||
} else {
|
||||
window = SwingUtilities.getWindowAncestor(component);
|
||||
}
|
||||
Window window = UIUtil.getWindow(component);
|
||||
|
||||
if (window instanceof IdeFrameImpl) {
|
||||
final Component pane = ((IdeFrameImpl) window).getGlassPane();
|
||||
|
||||
+17
-1
@@ -33,6 +33,7 @@ import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.RelativeFont;
|
||||
import com.intellij.ui.components.labels.LinkLabel;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.update.MergingUpdateQueue;
|
||||
import com.intellij.util.ui.update.Update;
|
||||
|
||||
@@ -149,7 +150,7 @@ class ConfigurableEditor extends AbstractEditor implements AnActionListener, AWT
|
||||
case MouseEvent.MOUSE_RELEASED:
|
||||
case MouseEvent.MOUSE_DRAGGED:
|
||||
MouseEvent me = (MouseEvent)event;
|
||||
if (isDescendingFrom(me.getComponent(), this)) {
|
||||
if (isDescendingFrom(me.getComponent(), this) || isPopupOverEditor(me.getComponent())) {
|
||||
requestUpdate();
|
||||
}
|
||||
break;
|
||||
@@ -178,6 +179,21 @@ class ConfigurableEditor extends AbstractEditor implements AnActionListener, AWT
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isPopupOverEditor(Component component) {
|
||||
Window editor = UIUtil.getWindow(this);
|
||||
if (editor != null) {
|
||||
Window popup = UIUtil.getWindow(component);
|
||||
if (popup != null && editor == popup.getParent()) {
|
||||
if (popup instanceof JDialog) {
|
||||
JDialog dialog = (JDialog)popup;
|
||||
return Dialog.ModalityType.MODELESS == dialog.getModalityType();
|
||||
}
|
||||
return popup instanceof JWindow;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void updateCurrent(Configurable configurable, boolean reset) {
|
||||
boolean modified = configurable != null && configurable.isModified();
|
||||
myApplyAction.setEnabled(modified);
|
||||
|
||||
@@ -203,10 +203,6 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
}
|
||||
myDialog.setModalityType(modalityType);
|
||||
}
|
||||
|
||||
if (Registry.is("suppress.focus.stealing")) {
|
||||
setAutoRequestFocus(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** @see DialogWrapper#DialogWrapper(boolean, boolean)
|
||||
@@ -248,6 +244,11 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
}
|
||||
|
||||
myDialog = new MyDialog(owner, myWrapper, myProject, myWindowFocusedCallback, myTypeAheadDone, myTypeAheadCallback);
|
||||
|
||||
if (Registry.is("suppress.focus.stealing")) {
|
||||
setAutoRequestFocus(false);
|
||||
}
|
||||
|
||||
myDialog.setModalityType(ideModalityType.toAwtModality());
|
||||
|
||||
myCanBeParent = canBeParent;
|
||||
|
||||
+6
-3
@@ -36,9 +36,12 @@ import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.StandardFileSystems;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.HttpRequests;
|
||||
import com.intellij.util.io.UrlConnectionUtil;
|
||||
@@ -648,11 +651,11 @@ public final class UpdateChecker {
|
||||
args.append('&');
|
||||
}
|
||||
|
||||
args.append(URLEncoder.encode(name, "UTF-8"));
|
||||
args.append(URLEncoder.encode(name, CharsetToolkit.UTF8));
|
||||
|
||||
String value = ourAdditionalRequestOptions.get(name);
|
||||
if (!StringUtil.isEmpty(value)) {
|
||||
args.append('=').append(URLEncoder.encode(value, "UTF-8"));
|
||||
args.append('=').append(URLEncoder.encode(value, CharsetToolkit.UTF8));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-20
@@ -47,6 +47,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
import gnu.trove.Equality;
|
||||
@@ -83,6 +84,7 @@ public class EncodingManagerImpl extends EncodingManager implements PersistentSt
|
||||
private final PropertyChangeSupport myPropertyChangeSupport = new PropertyChangeSupport(this);
|
||||
|
||||
static class State {
|
||||
@NotNull
|
||||
private Charset myDefaultEncoding = CharsetToolkit.UTF8_CHARSET;
|
||||
|
||||
@Attribute("default_encoding")
|
||||
@@ -92,17 +94,9 @@ public class EncodingManagerImpl extends EncodingManager implements PersistentSt
|
||||
}
|
||||
|
||||
public void setDefaultCharsetName(@NotNull String name) {
|
||||
if (name.isEmpty()) {
|
||||
myDefaultEncoding = ChooseFileEncodingAction.NO_ENCODING;
|
||||
return;
|
||||
}
|
||||
myDefaultEncoding = CharsetToolkit.forName(name);
|
||||
if (myDefaultEncoding == null) {
|
||||
myDefaultEncoding = CharsetToolkit.getDefaultSystemCharset();
|
||||
}
|
||||
if (myDefaultEncoding == null) {
|
||||
myDefaultEncoding = CharsetToolkit.UTF8_CHARSET;
|
||||
}
|
||||
myDefaultEncoding = name.isEmpty()
|
||||
? ChooseFileEncodingAction.NO_ENCODING
|
||||
: ObjectUtils.notNull(CharsetToolkit.forName(name), CharsetToolkit.getDefaultSystemCharset());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,10 +244,6 @@ public class EncodingManagerImpl extends EncodingManager implements PersistentSt
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseUTFGuessing(final VirtualFile virtualFile, final boolean useUTFGuessing) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNative2Ascii(@NotNull final VirtualFile virtualFile) {
|
||||
Project project = guessProject(virtualFile);
|
||||
@@ -305,11 +295,6 @@ public class EncodingManagerImpl extends EncodingManager implements PersistentSt
|
||||
EncodingProjectManager.getInstance(project).setDefaultCharsetForPropertiesFiles(virtualFile, charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(@NotNull PropertyChangeListener listener){
|
||||
myPropertyChangeSupport.addPropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(@NotNull final PropertyChangeListener listener, @NotNull Disposable parentDisposable) {
|
||||
myPropertyChangeSupport.addPropertyChangeListener(listener);
|
||||
|
||||
+18
-14
@@ -171,7 +171,8 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager implement
|
||||
if (parent == null) break;
|
||||
parent = parent.getParent();
|
||||
}
|
||||
return null;
|
||||
|
||||
return getDefaultCharset();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -331,7 +332,7 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager implement
|
||||
};
|
||||
}
|
||||
|
||||
private boolean processSubFiles(@Nullable("null means in the project") VirtualFile file, @NotNull final Processor<VirtualFile> processor) {
|
||||
private boolean processSubFiles(@Nullable("null means all in the project") VirtualFile file, @NotNull final Processor<VirtualFile> processor) {
|
||||
if (file == null) {
|
||||
for (VirtualFile virtualFile : ProjectRootManager.getInstance(myProject).getContentRoots()) {
|
||||
if (!processSubFiles(virtualFile, processor)) return false;
|
||||
@@ -349,10 +350,10 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager implement
|
||||
|
||||
//retrieves encoding for the Project node
|
||||
@Override
|
||||
@Nullable
|
||||
@NotNull
|
||||
public Charset getDefaultCharset() {
|
||||
Charset charset = getEncoding(null, false);
|
||||
return charset == null ? EncodingManager.getInstance().getDefaultCharset() : charset;
|
||||
return charset == null ? Charset.defaultCharset() : charset;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -360,10 +361,6 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager implement
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseUTFGuessing(final VirtualFile virtualFile, final boolean useUTFGuessing) {
|
||||
}
|
||||
|
||||
private static final ThreadLocal<Boolean> SUPPRESS_RELOAD = new ThreadLocal<Boolean>();
|
||||
static void suppressReloadDuring(@NotNull Runnable action) {
|
||||
Boolean old = SUPPRESS_RELOAD.get();
|
||||
@@ -388,7 +385,7 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager implement
|
||||
}, "Reload Files", false, myProject);
|
||||
}
|
||||
|
||||
private void reloadAllFilesUnder(final VirtualFile root) {
|
||||
private void reloadAllFilesUnder(@Nullable final VirtualFile root) {
|
||||
tryStartReloadWithProgress(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -435,6 +432,18 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager implement
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull // empty means system default
|
||||
@Override
|
||||
public String getDefaultCharsetName() {
|
||||
Charset charset = getEncoding(null, false);
|
||||
return charset == null ? "" : charset.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultCharsetName(@NotNull String name) {
|
||||
setEncoding(null, name.isEmpty() ? null : CharsetToolkit.forName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Charset getDefaultCharsetForPropertiesFiles(@Nullable final VirtualFile virtualFile) {
|
||||
@@ -450,11 +459,6 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager implement
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(@NotNull PropertyChangeListener listener){
|
||||
EncodingManager.getInstance().addPropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(@NotNull PropertyChangeListener listener, @NotNull Disposable parentDisposable) {
|
||||
EncodingManager.getInstance().addPropertyChangeListener(listener,parentDisposable);
|
||||
|
||||
+16
-1
@@ -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.openapi.vfs.encoding;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
@@ -19,7 +34,7 @@ import java.nio.charset.Charset;
|
||||
* @author yole
|
||||
*/
|
||||
public class PlatformFileEncodingConfigurable implements SearchableConfigurable {
|
||||
private static final String SYSTEM_DEFAULT = IdeBundle.message("encoding.name.system.default");
|
||||
private static final String SYSTEM_DEFAULT = IdeBundle.message("encoding.name.system.default", CharsetToolkit.getDefaultSystemCharset().displayName());
|
||||
private PlatformEncodingOptionsPanel myPanel;
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -21,7 +21,6 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.ThrowableComputable;
|
||||
import com.intellij.openapi.util.io.FileTooBigException;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VFileProperty;
|
||||
import com.intellij.openapi.vfs.VfsBundle;
|
||||
@@ -346,11 +345,13 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile {
|
||||
VfsData.invalidateFile(myId);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Charset getCharset() {
|
||||
return isCharsetSet() ? super.getCharset() : computeCharset();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Charset computeCharset() {
|
||||
Charset charset;
|
||||
if (isDirectory()) {
|
||||
|
||||
+2
-6
@@ -17,6 +17,7 @@ package com.intellij.openapi.wm.ex;
|
||||
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -56,12 +57,7 @@ public class LayoutFocusTraversalPolicyExt extends LayoutFocusTraversalPolicy{
|
||||
|
||||
@Nullable
|
||||
public static LayoutFocusTraversalPolicyExt findWindowPolicy(Component c) {
|
||||
Window wnd;
|
||||
if (c instanceof Window) {
|
||||
wnd = (Window)c;
|
||||
} else {
|
||||
wnd = SwingUtilities.getWindowAncestor(c);
|
||||
}
|
||||
Window wnd = UIUtil.getWindow(c);
|
||||
|
||||
final FocusTraversalPolicy policy = wnd.getFocusTraversalPolicy();
|
||||
if (policy instanceof LayoutFocusTraversalPolicyExt) {
|
||||
|
||||
@@ -109,8 +109,7 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
|
||||
|
||||
if (e instanceof MouseEvent) {
|
||||
MouseEvent me = (MouseEvent)e;
|
||||
Window eventWindow =
|
||||
me.getComponent() instanceof Window ? (Window)me.getComponent() : SwingUtilities.getWindowAncestor(me.getComponent());
|
||||
Window eventWindow = UIUtil.getWindow(me.getComponent());
|
||||
|
||||
if (isContextMenu(eventWindow)) return false;
|
||||
|
||||
@@ -155,7 +154,7 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
|
||||
MouseEvent me = (MouseEvent)e;
|
||||
final Component meComponent = me.getComponent();
|
||||
if (!dispatched && meComponent != null) {
|
||||
final Window eventWindow = meComponent instanceof Window ? (Window)meComponent : SwingUtilities.getWindowAncestor(meComponent);
|
||||
final Window eventWindow = UIUtil.getWindow(meComponent);
|
||||
if (eventWindow != SwingUtilities.getWindowAncestor(myRootPane)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -69,7 +69,7 @@ public class FocusTrackback {
|
||||
private boolean myForcedRestore;
|
||||
|
||||
public FocusTrackback(@NotNull Object requestor, Component parent, boolean mustBeShown) {
|
||||
this(requestor, parent == null || parent instanceof Window ? (Window)parent : SwingUtilities.getWindowAncestor(parent), mustBeShown);
|
||||
this(requestor, parent == null ? null : UIUtil.getWindow(parent), mustBeShown);
|
||||
}
|
||||
|
||||
public FocusTrackback(@NotNull Object requestor, Window parent, boolean mustBeShown) {
|
||||
@@ -263,7 +263,7 @@ public class FocusTrackback {
|
||||
}
|
||||
|
||||
if (myParentWindow != null) {
|
||||
final Window to = toFocus instanceof Window ? (Window) toFocus : SwingUtilities.getWindowAncestor(toFocus);
|
||||
final Window to = UIUtil.getWindow(toFocus);
|
||||
if (to != null && UIUtil.findUltimateParent(to) == UIUtil.findUltimateParent(myParentWindow)) { // IDEADEV-34537
|
||||
toFocus.requestFocus();
|
||||
result.setDone();
|
||||
@@ -490,7 +490,7 @@ public class FocusTrackback {
|
||||
public static List<JBPopup> getChildPopups(@NotNull final Component component) {
|
||||
List<JBPopup> result = new ArrayList<JBPopup>();
|
||||
|
||||
final Window window = component instanceof Window ? (Window)component: SwingUtilities.windowForComponent(component);
|
||||
final Window window = UIUtil.getWindow(component);
|
||||
if (window == null) return result;
|
||||
|
||||
final List<FocusTrackback> stack = getCleanStackForRoot(findUtlimateParent(window));
|
||||
|
||||
@@ -80,6 +80,11 @@ public class TabbedContentImpl extends ContentImpl implements TabbedContent {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return getTabName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectContent(int index) {
|
||||
Pair<String, JComponent> tab = myTabs.get(index);
|
||||
|
||||
@@ -1674,17 +1674,11 @@ public class AbstractPopup implements JBPopup {
|
||||
|
||||
if (owner == null) return false;
|
||||
|
||||
Window wnd;
|
||||
if (owner instanceof Window) {
|
||||
wnd = (Window)owner;
|
||||
}
|
||||
else {
|
||||
wnd = SwingUtilities.getWindowAncestor(owner);
|
||||
}
|
||||
Window wnd = UIUtil.getWindow(owner);
|
||||
|
||||
for (Component each : components) {
|
||||
if (each != null && SwingUtilities.isDescendingFrom(owner, each)) {
|
||||
Window eachWindow = each instanceof Window ? (Window)each : SwingUtilities.getWindowAncestor(each);
|
||||
Window eachWindow = UIUtil.getWindow(each);
|
||||
if (eachWindow == wnd) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public interface PopupComponent {
|
||||
throw new IllegalArgumentException("Popup owner must be showing");
|
||||
}
|
||||
|
||||
final Window wnd = owner instanceof Window ? (Window)owner: SwingUtilities.getWindowAncestor(owner);
|
||||
final Window wnd = UIUtil.getWindow(owner);
|
||||
if (wnd instanceof Frame) {
|
||||
myDialog = new JDialog((Frame)wnd);
|
||||
} else if (wnd instanceof Dialog) {
|
||||
|
||||
@@ -26,7 +26,6 @@ title.select.path.to.browser=Select Path to Browser
|
||||
title.general=System Settings
|
||||
editbox.default.encoding.for.properties.files=Default encoding for properties files:
|
||||
checkbox.transparent.native.to.ascii.conversion=Transparent native-to-ascii conversion
|
||||
checkbox.autodetect.utf=Autodetect UTF-encoded files
|
||||
group.http.proxy=HTTP Proxy
|
||||
group.web.browser=Web Browser
|
||||
group.general.options=General Options
|
||||
@@ -1091,7 +1090,7 @@ file.encodings.not.configured=Encodings are not configured
|
||||
encodings.dialog.caption=<html>To change encoding $productName uses for a file or directory, click an item and then select encoding from the Default Encoding list.<br><br>\
|
||||
Built-in file encoding (e.g. JSP, HTML or XML) overrides encoding you specify here.<br>\
|
||||
If not specified, files and directories inherit encoding settings from the parent directory or from the Project Encoding.</html>
|
||||
encoding.name.system.default=<System Default>
|
||||
encoding.name.system.default=<System Default> (now {0})
|
||||
quick.lists.presentable.name=Quick lists
|
||||
|
||||
error.saving.statistics=Error saving system information: {0}
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -115,7 +115,7 @@ public abstract class IntegrationTestCase extends PlatformTestCase {
|
||||
}
|
||||
|
||||
protected void setContent(VirtualFile f, String content, long timestamp) throws IOException {
|
||||
f.setBinaryContent(content.getBytes("UTF-8"), -1, timestamp);
|
||||
f.setBinaryContent(content.getBytes(CharsetToolkit.UTF8_CHARSET), -1, timestamp);
|
||||
}
|
||||
|
||||
protected String createFileExternally(String name) throws IOException {
|
||||
@@ -126,7 +126,7 @@ public abstract class IntegrationTestCase extends PlatformTestCase {
|
||||
File f = new File(myRoot.getPath(), name);
|
||||
assertTrue(f.getPath(), f.getParentFile().mkdirs() || f.getParentFile().isDirectory());
|
||||
assertTrue(f.getPath(), f.createNewFile() || f.exists());
|
||||
if (content != null) FileUtil.writeToFile(f, content.getBytes("UTF-8"));
|
||||
if (content != null) FileUtil.writeToFile(f, content.getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
return FileUtil.toSystemIndependentName(f.getPath());
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public abstract class IntegrationTestCase extends PlatformTestCase {
|
||||
|
||||
protected void setContentExternally(String path, String content) throws IOException {
|
||||
File f = new File(path);
|
||||
FileUtil.writeToFile(f, content.getBytes("UTF-8"));
|
||||
FileUtil.writeToFile(f, content.getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
assertTrue(f.getPath(), f.setLastModified(f.lastModified() + 2000));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.testFramework.PlatformLangTestCase;
|
||||
|
||||
import java.io.File;
|
||||
@@ -29,7 +30,7 @@ public class LocatorTest extends PlatformLangTestCase {
|
||||
assertTrue("doesn't exist: " + locatorFile.getPath(), locatorFile.exists());
|
||||
assertTrue("can't read: " + locatorFile.getPath(), locatorFile.canRead());
|
||||
|
||||
String home = FileUtil.loadFile(locatorFile, "UTF-8");
|
||||
String home = FileUtil.loadFile(locatorFile, CharsetToolkit.UTF8_CHARSET);
|
||||
assertTrue(home, StringUtil.isNotEmpty(home));
|
||||
|
||||
assertEquals(home, PathManager.getHomePath());
|
||||
|
||||
+6
-6
@@ -150,7 +150,7 @@ public class FileDocumentManagerImplTest extends PlatformLangTestCase {
|
||||
final Document[] unsavedDocuments = myDocumentManager.getUnsavedDocuments();
|
||||
assertEquals(1, unsavedDocuments.length);
|
||||
assertSame(document, unsavedDocuments[0]);
|
||||
assertEquals("test", new String(file.contentsToByteArray(), "UTF-8"));
|
||||
assertEquals("test", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
|
||||
public void testGetUnsavedDocuments_afterSaveAllDocuments() throws Exception {
|
||||
@@ -218,7 +218,7 @@ public class FileDocumentManagerImplTest extends PlatformLangTestCase {
|
||||
final Document[] unsavedDocuments = myDocumentManager.getUnsavedDocuments();
|
||||
assertEquals(1, unsavedDocuments.length);
|
||||
assertSame(document, unsavedDocuments[0]);
|
||||
assertEquals("test", new String(file.contentsToByteArray(), "UTF-8"));
|
||||
assertEquals("test", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
finally {
|
||||
myDocumentManager.dropAllUnsavedDocuments();
|
||||
@@ -296,7 +296,7 @@ public class FileDocumentManagerImplTest extends PlatformLangTestCase {
|
||||
myDocumentManager.saveDocument(document);
|
||||
assertTrue(stamp != file.getModificationStamp());
|
||||
assertEquals(document.getModificationStamp(), file.getModificationStamp());
|
||||
assertEquals("xxx test", new String(file.contentsToByteArray(), "UTF-8"));
|
||||
assertEquals("xxx test", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
|
||||
public void testSaveAllDocuments_DocumentWasChanged() throws Exception {
|
||||
@@ -313,7 +313,7 @@ public class FileDocumentManagerImplTest extends PlatformLangTestCase {
|
||||
|
||||
myDocumentManager.saveAllDocuments();
|
||||
assertNotEquals(stamp, file.getModificationStamp());
|
||||
assertEquals("xxx test", new String(file.contentsToByteArray(), "UTF-8"));
|
||||
assertEquals("xxx test", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
|
||||
public void testGetFile() throws Exception {
|
||||
@@ -342,7 +342,7 @@ public class FileDocumentManagerImplTest extends PlatformLangTestCase {
|
||||
});
|
||||
|
||||
myDocumentManager.saveAllDocuments();
|
||||
assertEquals("xxx test\rtest", new String(file.contentsToByteArray(), "UTF-8"));
|
||||
assertEquals("xxx test\rtest", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
|
||||
}
|
||||
|
||||
public void testContentChanged_noDocument() throws Exception {
|
||||
@@ -532,7 +532,7 @@ public class FileDocumentManagerImplTest extends PlatformLangTestCase {
|
||||
|
||||
assertEquals("old test", document.getText());
|
||||
assertEquals(file.getModificationStamp(), document.getModificationStamp());
|
||||
assertEquals("old test", new String(file.contentsToByteArray(), "UTF-8"));
|
||||
assertEquals("old test", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
|
||||
assertEquals(documentStamp, document.getModificationStamp());
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ public class VfsUtilTest extends PlatformLangTestCase {
|
||||
|
||||
private static void doAsyncRefreshTest(File temp) throws Exception {
|
||||
final int N = 1000;
|
||||
final byte[] data = "xxx".getBytes("UTF-8");
|
||||
final byte[] data = "xxx".getBytes(CharsetToolkit.UTF8_CHARSET);
|
||||
|
||||
LocalFileSystem fs = LocalFileSystem.getInstance();
|
||||
VirtualFile vTemp = fs.findFileByIoFile(temp);
|
||||
|
||||
+1
-1
@@ -284,7 +284,7 @@ public class LocalFileSystemTest extends PlatformLangTestCase {
|
||||
|
||||
final VirtualFile file = myFS.refreshAndFindFileByIoFile(targetFile);
|
||||
assertNotNull(file);
|
||||
file.setBinaryContent("hello".getBytes("UTF-8"), 0, 0, requestor);
|
||||
file.setBinaryContent("hello".getBytes(CharsetToolkit.UTF8_CHARSET), 0, 0, requestor);
|
||||
assertTrue(file.getLength() > 0);
|
||||
|
||||
final VirtualFile check = myFS.refreshAndFindFileByIoFile(hardLinkFile);
|
||||
|
||||
+4
-2
@@ -20,7 +20,9 @@ import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.injected.editor.DocumentWindow;
|
||||
import com.intellij.injected.editor.EditorWindow;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
@@ -291,7 +293,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
|
||||
assertTrue(getMessage("Cannot find file " + fullPath, message), ioFile.exists());
|
||||
String fileText = null;
|
||||
try {
|
||||
fileText = FileUtil.loadFile(ioFile, CharsetToolkit.UTF8);
|
||||
fileText = FileUtil.loadFile(ioFile, CharsetToolkit.UTF8_CHARSET);
|
||||
} catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
@@ -783,7 +783,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
|
||||
return file;
|
||||
}
|
||||
|
||||
public static void setContentOnDisk(File file, byte[] bom, String content, Charset charset) throws IOException {
|
||||
public static void setContentOnDisk(@NotNull File file, byte[] bom, @NotNull String content, @NotNull Charset charset) throws IOException {
|
||||
FileOutputStream stream = new FileOutputStream(file);
|
||||
if (bom != null) {
|
||||
stream.write(bom);
|
||||
@@ -797,7 +797,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
|
||||
}
|
||||
}
|
||||
|
||||
public static VirtualFile createTempFile(@NonNls String ext, @Nullable byte[] bom, @NonNls String content, Charset charset) throws IOException {
|
||||
public static VirtualFile createTempFile(@NonNls @NotNull String ext, @Nullable byte[] bom, @NonNls @NotNull String content, @NotNull Charset charset) throws IOException {
|
||||
File temp = FileUtil.createTempFile("copy", "." + ext);
|
||||
setContentOnDisk(temp, bom, content, charset);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* @return the VirtualFile for the copied directory in the test project directory.
|
||||
*/
|
||||
@NotNull
|
||||
VirtualFile copyDirectoryToProject(@NonNls @NotNull String sourceFilePath, @NonNls @NotNull String targetPath);
|
||||
VirtualFile copyDirectoryToProject(@TestDataFile @NonNls @NotNull String sourceFilePath, @NonNls @NotNull String targetPath);
|
||||
|
||||
/**
|
||||
* Copies a file from the testdata directory to the same relative path in the test project directory.
|
||||
|
||||
@@ -27,6 +27,10 @@ public class Pair<A, B> {
|
||||
//noinspection DontUsePairConstructor
|
||||
return new Pair<A, B>(first, second);
|
||||
}
|
||||
@NotNull
|
||||
public static <A, B> NonNull<A, B> createNonNull(@NotNull A first, @NotNull B second) {
|
||||
return new NonNull<A, B>(first, second);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("MethodNamesDifferingOnlyByCase")
|
||||
@@ -38,6 +42,7 @@ public class Pair<A, B> {
|
||||
@NotNull
|
||||
public static <A, B> Function<A, Pair<A, B>> createFunction(final B value) {
|
||||
return new Function<A, Pair<A, B>>() {
|
||||
@Override
|
||||
public Pair<A, B> fun(A a) {
|
||||
return create(a, value);
|
||||
}
|
||||
@@ -73,17 +78,26 @@ public class Pair<A, B> {
|
||||
return second;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
return o instanceof Pair && Comparing.equal(first, ((Pair)o).first) && Comparing.equal(second, ((Pair)o).second);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = first != null ? first.hashCode() : 0;
|
||||
result = 31 * result + (second != null ? second.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "<" + first + "," + second + ">";
|
||||
}
|
||||
|
||||
public static class NonNull<A, B> extends Pair<A,B> {
|
||||
public NonNull(@NotNull A first, @NotNull B second) {
|
||||
super(first, second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -381,7 +382,7 @@ public class FileUtilRt {
|
||||
|
||||
@NotNull
|
||||
public static char[] loadFileText(@NotNull File file) throws IOException {
|
||||
return loadFileText(file, null);
|
||||
return loadFileText(file, (String)null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -396,6 +397,16 @@ public class FileUtilRt {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
@NotNull
|
||||
public static char[] loadFileText(@NotNull File file, @NotNull @NonNls Charset encoding) throws IOException {
|
||||
Reader reader = new InputStreamReader(new FileInputStream(file), encoding);
|
||||
try {
|
||||
return loadText(reader, (int)file.length());
|
||||
}
|
||||
finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static char[] loadText(@NotNull Reader reader, int length) throws IOException {
|
||||
|
||||
@@ -15,13 +15,11 @@
|
||||
*/
|
||||
package com.intellij.openapi.diagnostic;
|
||||
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.Base64Converter;
|
||||
import com.intellij.util.PathUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class Attachment {
|
||||
public static final Attachment[] EMPTY_ARRAY = new Attachment[0];
|
||||
private final String myPath;
|
||||
@@ -43,12 +41,7 @@ public class Attachment {
|
||||
|
||||
@NotNull
|
||||
public static byte[] getBytes(@NotNull String content) {
|
||||
try {
|
||||
return content.getBytes("UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException ignored) {
|
||||
return ArrayUtil.EMPTY_BYTE_ARRAY;
|
||||
}
|
||||
return content.getBytes(CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.CommonBundle;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.concurrency.FixedFuture;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -32,6 +33,7 @@ import org.jetbrains.annotations.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
@@ -1116,7 +1118,7 @@ public class FileUtil extends FileUtilRt {
|
||||
}
|
||||
|
||||
public static void appendToFile(@NotNull File file, @NotNull String text) throws IOException {
|
||||
writeToFile(file, text.getBytes("UTF-8"), true);
|
||||
writeToFile(file, text.getBytes(CharsetToolkit.UTF8_CHARSET), true);
|
||||
}
|
||||
|
||||
public static void writeToFile(@NotNull File file, @NotNull byte[] text) throws IOException {
|
||||
@@ -1124,7 +1126,7 @@ public class FileUtil extends FileUtilRt {
|
||||
}
|
||||
|
||||
public static void writeToFile(@NotNull File file, @NotNull String text) throws IOException {
|
||||
writeToFile(file, text.getBytes("UTF-8"), false);
|
||||
writeToFile(file, text.getBytes(CharsetToolkit.UTF8_CHARSET), false);
|
||||
}
|
||||
|
||||
public static void writeToFile(@NotNull File file, @NotNull byte[] text, int off, int len) throws IOException {
|
||||
@@ -1421,6 +1423,10 @@ public class FileUtil extends FileUtilRt {
|
||||
public static String loadFile(@NotNull File file, @Nullable @NonNls String encoding) throws IOException {
|
||||
return FileUtilRt.loadFile(file, encoding);
|
||||
}
|
||||
@NotNull
|
||||
public static String loadFile(@NotNull File file, @NotNull @NonNls Charset encoding) throws IOException {
|
||||
return String.valueOf(FileUtilRt.loadFileText(file, encoding));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String loadFile(@NotNull File file, @Nullable @NonNls String encoding, boolean convertLineSeparators) throws IOException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,9 +18,11 @@ package com.intellij.openapi.util.io;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.io.UnsyncByteArrayOutputStream;
|
||||
import com.intellij.util.text.StringFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class StreamUtil {
|
||||
private StreamUtil() {
|
||||
@@ -64,7 +66,11 @@ public class StreamUtil {
|
||||
return new String(data);
|
||||
}
|
||||
|
||||
public static String readText(InputStream inputStream, String encoding) throws IOException {
|
||||
public static String readText(InputStream inputStream, @NotNull String encoding) throws IOException {
|
||||
final byte[] data = loadFromStream(inputStream);
|
||||
return new String(data, encoding);
|
||||
}
|
||||
public static String readText(InputStream inputStream, @NotNull Charset encoding) throws IOException {
|
||||
final byte[] data = loadFromStream(inputStream);
|
||||
return new String(data, encoding);
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ public class CharsetToolkit {
|
||||
private static final int BINARY_THRESHOLD = 9; // characters with codes below this considered to be binary
|
||||
|
||||
private final byte[] buffer;
|
||||
@NotNull
|
||||
private final Charset defaultCharset;
|
||||
private boolean enforce8Bit = false;
|
||||
|
||||
@@ -122,9 +123,9 @@ public class CharsetToolkit {
|
||||
* @param buffer the byte buffer of which we want to know the encoding.
|
||||
* @param defaultCharset the default Charset to use in case an 8-bit charset is recognized.
|
||||
*/
|
||||
public CharsetToolkit(@NotNull byte[] buffer, Charset defaultCharset) {
|
||||
public CharsetToolkit(@NotNull byte[] buffer, @NotNull Charset defaultCharset) {
|
||||
this.buffer = buffer;
|
||||
this.defaultCharset = defaultCharset == null ? getDefaultSystemCharset() : defaultCharset;
|
||||
this.defaultCharset = defaultCharset;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -240,6 +241,7 @@ public class CharsetToolkit {
|
||||
/**
|
||||
* Retrieves the default Charset
|
||||
*/
|
||||
@NotNull
|
||||
public Charset getDefaultCharset() {
|
||||
return defaultCharset;
|
||||
}
|
||||
@@ -268,7 +270,7 @@ public class CharsetToolkit {
|
||||
*
|
||||
* @return the Charset recognized.
|
||||
*/
|
||||
public Charset guessEncoding(int guess_length, Charset defaultCharset) {
|
||||
public Charset guessEncoding(int guess_length, @NotNull Charset defaultCharset) {
|
||||
// if the file has a Byte Order Marker, we can assume the file is in UTF-xx
|
||||
// otherwise, the file would not be human readable
|
||||
Charset charset = guessFromBOM();
|
||||
@@ -436,7 +438,7 @@ public class CharsetToolkit {
|
||||
return guessEncoding(guess_length, defaultCharset);
|
||||
}
|
||||
|
||||
public static Charset guessEncoding(@NotNull File f, int bufferLength, Charset defaultCharset) throws IOException {
|
||||
public static Charset guessEncoding(@NotNull File f, int bufferLength, @NotNull Charset defaultCharset) throws IOException {
|
||||
byte[] buffer = new byte[bufferLength];
|
||||
int read;
|
||||
FileInputStream fis = new FileInputStream(f);
|
||||
@@ -515,16 +517,9 @@ public class CharsetToolkit {
|
||||
*
|
||||
* @return the default <code>Charset</code>.
|
||||
*/
|
||||
@Nullable
|
||||
@NotNull
|
||||
public static Charset getDefaultSystemCharset() {
|
||||
Charset charset = null;
|
||||
try {
|
||||
charset = Charset.forName(System.getProperty(FILE_ENCODING_PROPERTY));
|
||||
} catch (Exception ignored) {
|
||||
// Null is OK here.
|
||||
}
|
||||
|
||||
return charset;
|
||||
return Charset.defaultCharset();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -587,8 +582,8 @@ public class CharsetToolkit {
|
||||
}
|
||||
}
|
||||
|
||||
public static int getBOMLength(@NotNull byte[] content, Charset charset) {
|
||||
if (charset != null && charset.name().contains(UTF8) && hasUTF8Bom(content)) {
|
||||
public static int getBOMLength(@NotNull byte[] content, @NotNull Charset charset) {
|
||||
if (charset.name().contains(UTF8) && hasUTF8Bom(content)) {
|
||||
return UTF8_BOM.length;
|
||||
}
|
||||
if (hasUTF32BEBom(content)) {
|
||||
@@ -606,14 +601,6 @@ public class CharsetToolkit {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link CharsetToolkit#getMandatoryBom(java.nio.charset.Charset)}
|
||||
*/
|
||||
@Nullable
|
||||
public static byte[] getBom(@NotNull Charset charset) {
|
||||
return getMandatoryBom(charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BOM which is associated with this charset and the charset must have this BOM, or null otherwise.
|
||||
* Currently these are UTF-16xx and UTF-32xx families.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.util;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.io.URLUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -33,7 +34,6 @@ import java.util.Locale;
|
||||
* @author max
|
||||
*/
|
||||
public class ResourceUtil {
|
||||
@NonNls private static final String ENCODING_UTF_8 = "UTF-8";
|
||||
|
||||
private ResourceUtil() {
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class ResourceUtil {
|
||||
public static String loadText(@NotNull URL url) throws IOException {
|
||||
InputStream inputStream = new BufferedInputStream(URLUtil.openStream(url));
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(inputStream, ENCODING_UTF_8);
|
||||
InputStreamReader reader = new InputStreamReader(inputStream, CharsetToolkit.UTF8_CHARSET);
|
||||
try {
|
||||
StringBuilder text = new StringBuilder();
|
||||
char[] buf = new char[5000];
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.intellij.util.io;
|
||||
|
||||
import com.intellij.openapi.Forceable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.*;
|
||||
@@ -138,27 +139,16 @@ public class RandomAccessDataFile implements Forceable, Closeable {
|
||||
}
|
||||
|
||||
public String getUTF(long addr) {
|
||||
try {
|
||||
int len = getInt(addr);
|
||||
byte[] bytes = new byte[len];
|
||||
get(addr + 4, bytes, 0, len);
|
||||
return new String(bytes, "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
// Can't be
|
||||
return "";
|
||||
}
|
||||
int len = getInt(addr);
|
||||
byte[] bytes = new byte[len];
|
||||
get(addr + 4, bytes, 0, len);
|
||||
return new String(bytes, CharsetToolkit.UTF8_CHARSET);
|
||||
}
|
||||
|
||||
public void putUTF(long addr, String value) {
|
||||
try {
|
||||
final byte[] bytes = value.getBytes("UTF-8");
|
||||
putInt(addr, bytes.length);
|
||||
put(addr + 4, bytes, 0, bytes.length);
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
// Can't be
|
||||
}
|
||||
final byte[] bytes = value.getBytes(CharsetToolkit.UTF8_CHARSET);
|
||||
putInt(addr, bytes.length);
|
||||
put(addr + 4, bytes, 0, bytes.length);
|
||||
}
|
||||
|
||||
public long length() {
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
@@ -169,7 +168,7 @@ public class URLUtil {
|
||||
for (int j = 0; j < bytes.size(); j++) {
|
||||
bytesArray[j] = (byte)bytes.getQuick(j);
|
||||
}
|
||||
decoded.append(new String(bytesArray, Charset.forName("UTF-8")));
|
||||
decoded.append(new String(bytesArray, CharsetToolkit.UTF8_CHARSET));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3217,4 +3217,16 @@ public class UIUtil {
|
||||
|
||||
textField.setColumns(4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first window ancestor of the component.
|
||||
* Note that this method returns the component itself if it is a window.
|
||||
*
|
||||
* @param component the component used to find corresponding window
|
||||
* @return the first window ancestor of the component; or {@code null}
|
||||
* if the component is not a window and is not contained inside a window
|
||||
*/
|
||||
public static Window getWindow(Component component) {
|
||||
return component instanceof Window ? (Window)component : SwingUtilities.getWindowAncestor(component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user