Commit edc47905 authored by Gregory.Shrago's avatar Gregory.Shrago Committed by intellij-monorepo-bot
Browse files

migrate to StringUtil.toLower/UpperCase, ENGLISH locale

GitOrigin-RevId: 3a8627e7aef5991ee840996c6f7f147d1f747a3b
parent e749d0eb
Showing with 43 additions and 36 deletions
+43 -36
......@@ -15,13 +15,13 @@
*/
package org.intellij.lang.regexp;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ReflectionUtil;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.function.Consumer;
/**
......@@ -96,7 +96,7 @@ public class UnicodeCharacterNames {
return -1; // give up
}
byte[] namePool = (byte[])initNamePool.invoke(null);
name = name.trim().toUpperCase(Locale.ROOT);
name = StringUtil.toUpperCase(name.trim());
byte[] key = name.getBytes(StandardCharsets.ISO_8859_1);
final int[][] lookup = ReflectionUtil.getField(aClass, null, int[][].class, "lookup");
if (lookup == null) throw new RuntimeException();
......
......@@ -48,8 +48,10 @@ import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.*;
import java.util.Map;
import static com.intellij.openapi.wm.impl.IdeBackgroundUtil.*;
......@@ -473,7 +475,7 @@ public class BackgroundImageDialog extends DialogWrapper {
IdeBackgroundUtil.Anchor[] values = IdeBackgroundUtil.Anchor.values();
String[] names = new String[values.length];
for (int i = 0; i < names.length; i++) {
names[i] = values[i].name().replace('_', '-').toLowerCase(Locale.ENGLISH);
names[i] = StringUtil.toLowerCase(values[i].name().replace('_', '-'));
}
Color color = getSelectionBackground();
p.setLayout(new GridLayout(3, 3, 1, 1));
......@@ -490,7 +492,7 @@ public class BackgroundImageDialog extends DialogWrapper {
String[] names = new String[values.length];
BufferedImage image = sampleImage();
for (int i = 0; i < names.length; i++) {
names[i] = values[i].name().replace('_', '-').toLowerCase(Locale.ENGLISH);
names[i] = StringUtil.toLowerCase(values[i].name().replace('_', '-'));
}
Color color = getSelectionBackground();
p.setLayout(new GridLayout(1, values.length, 1, 1));
......
......@@ -69,7 +69,6 @@ import java.beans.PropertyChangeListener;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.net.URL;
import java.util.Locale;
/**
* Image editor UI
......@@ -193,7 +192,7 @@ final class ImageEditorUI extends JPanel implements DataProvider, CopyProvider,
if (format == null) {
format = editor != null ? ImagesBundle.message("unknown.format") : "";
} else {
format = format.toUpperCase(Locale.ENGLISH);
format = StringUtil.toUpperCase(format);
}
VirtualFile file = editor != null ? editor.getFile() : null;
infoLabel.setText(
......
......@@ -30,7 +30,6 @@ import org.jetbrains.annotations.NotNull;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.util.Locale;
import java.util.Set;
/**
......@@ -68,9 +67,9 @@ final class ImageFileTypeManagerImpl extends ImageFileTypeManager {
public void createFileTypes(final @NotNull FileTypeConsumer consumer) {
final Set<String> processed = new THashSet<>();
for (String format : ImageIO.getReaderFormatNames()) {
processed.add(format.toLowerCase(Locale.ENGLISH));
processed.add(StringUtil.toLowerCase(format));
}
processed.add(IfsUtil.ICO_FORMAT.toLowerCase(Locale.ENGLISH));
processed.add(StringUtil.toLowerCase(IfsUtil.ICO_FORMAT));
consumer.consume(IMAGE_FILE_TYPE, StringUtil.join(processed, FileTypeConsumer.EXTENSION_DELIMITER));
consumer.consume(SvgFileType.INSTANCE, "svg");
......
......@@ -17,6 +17,7 @@ package org.intellij.images.ui;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.JBColor;
import com.intellij.util.ui.UIUtil;
import icons.ImagesIcons;
......@@ -136,7 +137,7 @@ public class ThumbnailComponentUI extends ComponentUI {
Font font = getSmallFont().deriveFont(Font.BOLD);
FontMetrics fontMetrics = g.getFontMetrics(font);
String format = tc.getFormat().toUpperCase();
String format = StringUtil.toUpperCase(tc.getFormat());
int stringWidth = fontMetrics.stringWidth(format);
int x = ImagesIcons.ThumbnailBlank.getIconWidth() - stringWidth + 2;
int y = ImagesIcons.ThumbnailBlank.getIconHeight() - fontMetrics.getHeight() + 4;
......
......@@ -22,6 +22,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NonNls;
import java.io.File;
......@@ -81,7 +82,7 @@ public class CompilerCacheManager implements Disposable {
public static String getCompilerIdString(Compiler compiler) {
@NonNls String description = compiler.getDescription();
return description.replaceAll("\\s+", "_").replaceAll("[\\.\\?]", "_").toLowerCase();
return StringUtil.toLowerCase(description.replaceAll("\\s+", "_").replaceAll("[\\.\\?]", "_"));
}
synchronized void flushCaches() {
......
......@@ -582,10 +582,10 @@ public class Javac2 extends Javac {
return myFormCache.get(formFilePath);
}
String lowerFormFilePath = formFilePath.toLowerCase();
String lowerFormFilePath = formFilePath.toLowerCase(Locale.ENGLISH);
log("Searching for form " + lowerFormFilePath, Project.MSG_VERBOSE);
for (File file : myFormFiles) {
String name = file.getAbsolutePath().replace(File.separatorChar, '/').toLowerCase();
String name = file.getAbsolutePath().replace(File.separatorChar, '/').toLowerCase(Locale.ENGLISH);
log("Comparing with " + name, Project.MSG_VERBOSE);
if (name.endsWith(lowerFormFilePath)) {
return loadForm(formFilePath, new FileInputStream(file));
......
......@@ -19,6 +19,7 @@ import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
import java.io.File;
import java.util.Locale;
/**
* Allows to specify relative output prefix for Path.
......@@ -50,7 +51,7 @@ public class PrefixedPath extends Path {
String prefix = myPrefix;
if (prefix != null) {
prefix = trimStartSlash(ensureEndsWithSlash(prefix));
if (!relativePath.toLowerCase().startsWith(prefix.toLowerCase())) {
if (!relativePath.toLowerCase(Locale.ENGLISH).startsWith(prefix.toLowerCase(Locale.ENGLISH))) {
return null;
}
relativePath = relativePath.substring(prefix.length());
......
......@@ -21,6 +21,7 @@ import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NonNls;
......@@ -223,7 +224,7 @@ public abstract class BuildProperties extends CompositeGenerator {
*/
@NonNls
public static String convertName(@NonNls final String name) {
return name.replaceAll("\"", "").replaceAll("\\s+", "_").toLowerCase();
return StringUtil.toLowerCase(name.replaceAll("\"", "").replaceAll("\\s+", "_"));
}
@NonNls
......
......@@ -4,6 +4,7 @@ package com.intellij.debugger.ui.tree.render;
import com.intellij.debugger.engine.evaluation.EvaluationContext;
import com.intellij.debugger.ui.tree.ValueDescriptor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
import com.sun.jdi.*;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
......@@ -59,27 +60,27 @@ public class HexRenderer extends NodeRendererImpl {
static void appendHexValue(@NotNull PrimitiveValue value, StringBuilder buf) {
if (value instanceof CharValue) {
long longValue = value.longValue();
buf.append("0x").append(Long.toHexString(longValue).toUpperCase());
buf.append("0x").append(StringUtil.toUpperCase(Long.toHexString(longValue)));
}
else if (value instanceof ByteValue) {
String strValue = Integer.toHexString(value.byteValue()).toUpperCase();
String strValue = StringUtil.toUpperCase(Integer.toHexString(value.byteValue()));
if (strValue.length() > 2) {
strValue = strValue.substring(strValue.length() - 2);
}
buf.append("0x").append(strValue);
}
else if (value instanceof ShortValue) {
String strValue = Integer.toHexString(value.shortValue()).toUpperCase();
String strValue = StringUtil.toUpperCase(Integer.toHexString(value.shortValue()));
if (strValue.length() > 4) {
strValue = strValue.substring(strValue.length() - 4);
}
buf.append("0x").append(strValue);
}
else if (value instanceof IntegerValue) {
buf.append("0x").append(Integer.toHexString(value.intValue()).toUpperCase());
buf.append("0x").append(StringUtil.toUpperCase(Integer.toHexString(value.intValue())));
}
else if (value instanceof LongValue) {
buf.append("0x").append(Long.toHexString(value.longValue()).toUpperCase());
buf.append("0x").append(StringUtil.toUpperCase(Long.toHexString(value.longValue())));
}
else {
LOG.assertTrue(false);
......
......@@ -273,8 +273,7 @@ public abstract class JavaTestFrameworkRunnableState<T extends
}
} else if (isExecutorDisabledInForkedMode()) {
final String actionName = executor.getActionName();
throw new CantRunException(actionName + " is disabled in fork mode.<br/>Please change fork mode to &lt;none&gt; to " + actionName.toLowerCase(
Locale.ENGLISH) + ".");
throw new CantRunException(actionName + " is disabled in fork mode.<br/>Please change fork mode to &lt;none&gt; to " + StringUtil.toLowerCase(actionName) + ".");
}
final JavaParameters javaParameters = getJavaParameters();
......
......@@ -128,7 +128,7 @@ public abstract class ChangeLibraryLevelActionBase extends AnAction {
}
catch (IOException e) {
final String actionName = getActionName();
final String message = "Cannot " + actionName.toLowerCase() + " file " + from.getAbsolutePath() + ": " + e.getMessage();
final String message = "Cannot " + StringUtil.toLowerCase(actionName) + " file " + from.getAbsolutePath() + ": " + e.getMessage();
Messages.showErrorDialog(ChangeLibraryLevelActionBase.this.myProject, message, "Cannot " + actionName);
LOG.info(e);
return;
......
......@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.roots.ui.configuration.libraryEditor;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.TreeSpeedSearch;
import com.intellij.ui.treeStructure.Tree;
......@@ -40,7 +41,7 @@ class LibraryRootsTreeSpeedSearch extends TreeSpeedSearch {
return false;
}
if (!hasCapitals(pattern)) { // be case-sensitive only if user types capitals
str = str.toLowerCase();
str = StringUtil.toLowerCase(str);
}
if (pattern.contains(File.separator)) {
return compare(str,pattern);
......
......@@ -40,7 +40,7 @@ public interface LibrariesContainer {
enum LibraryLevel {GLOBAL, PROJECT, MODULE;
public String toString() {
return StringUtil.capitalize(name().toLowerCase());
return StringUtil.capitalize(StringUtil.toLowerCase(name()));
}
}
......
......@@ -1011,7 +1011,7 @@ public class HighlightUtil extends HighlightUtilBase {
boolean isInt = PsiLiteralExpressionImpl.INTEGER_LITERALS.contains(type);
boolean isFP = PsiLiteralExpressionImpl.REAL_LITERALS.contains(type);
String text = isInt || isFP ? literal.getText().toLowerCase() : literal.getText();
String text = isInt || isFP ? StringUtil.toLowerCase(literal.getText()) : literal.getText();
Object value = expression.getValue();
if (file != null) {
......
......@@ -14,7 +14,8 @@ import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import static com.intellij.patterns.PsiJavaPatterns.*;
import static com.intellij.patterns.PsiJavaPatterns.or;
import static com.intellij.patterns.PsiJavaPatterns.psiElement;
/**
* @author Dmitry Batkovich
......@@ -71,7 +72,7 @@ public class BlockMarkerCommentsInspection extends AbstractBaseJavaLocalInspecti
if (prefix != null && rawCommentText.startsWith(prefix)) {
rawCommentText = rawCommentText.substring(prefix.length());
}
final String commentText = rawCommentText.trim().toLowerCase();
final String commentText = StringUtil.toLowerCase(rawCommentText.trim());
if (!commentText.startsWith(END_WORD) || StringUtil.split(commentText, " ").size() > 3) {
return;
}
......
......@@ -9,6 +9,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiTypesUtil;
......@@ -353,7 +354,7 @@ final class DataFlowInstructionVisitor extends StandardInstructionVisitor {
@NotNull
@Override
public String toString() {
return name().toLowerCase(Locale.ENGLISH);
return StringUtil.toLowerCase(name());
}
public Object value() {
......
......@@ -268,9 +268,9 @@ public class JavaColorProvider implements ElementColorProvider {
text = "0x";
Color c = new Color(newValue, hasAlpha);
if (hasAlpha) {
text += Integer.toHexString(c.getAlpha()).toUpperCase();
text += StringUtil.toUpperCase(Integer.toHexString(c.getAlpha()));
}
text += ColorUtil.toHex(c).toUpperCase();
text += StringUtil.toUpperCase(ColorUtil.toHex(c));
}
else {
text = Integer.toString(newValue);
......
......@@ -19,6 +19,7 @@ import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.refactoring.changeClassSignature.ChangeClassSignatureDialog;
import com.intellij.refactoring.changeClassSignature.TypeParameterInfo;
......@@ -175,7 +176,7 @@ public class ChangeClassSignatureFromUsageFix extends BaseIntentionAction {
@NotNull
public String suggest(@NotNull PsiClassType type) {
return suggestUnusedName(type.getClassName().substring(0, 1).toUpperCase());
return suggestUnusedName(StringUtil.toUpperCase(type.getClassName().substring(0, 1)));
}
}
......
......@@ -20,11 +20,10 @@
package com.intellij.codeInsight.daemon.impl.quickfix;
import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiReferenceExpression;
import org.jetbrains.annotations.NotNull;
import java.util.Locale;
public class CreateConstantFieldFromUsageFix extends CreateFieldFromUsageFix {
@Override
protected boolean createConstantField() {
......@@ -35,7 +34,7 @@ public class CreateConstantFieldFromUsageFix extends CreateFieldFromUsageFix {
protected boolean isAvailableImpl(int offset) {
if (!super.isAvailableImpl(offset)) return false;
String refName = myReferenceExpression.getReferenceName();
return refName.toUpperCase(Locale.ENGLISH).equals(refName);
return StringUtil.toUpperCase(refName).equals(refName);
}
public CreateConstantFieldFromUsageFix(PsiReferenceExpression referenceElement) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment