Skip to content

Commit

Permalink
More consistent StringUtil usage (#7782)
Browse files Browse the repository at this point in the history
Enforcement of this added into the `./bin/plugin lint` cli tool

Additional context: dart-lang/sdk#39377
  • Loading branch information
jwren authored Nov 12, 2024
1 parent 66e105e commit 0c045af
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ui.ColorIcon;
import com.intellij.util.ui.EmptyIcon;
import com.jetbrains.lang.dart.ide.completion.DartCompletionExtension;
import com.jetbrains.lang.dart.ide.completion.DartServerCompletionContributor;
import org.apache.commons.lang3.StringUtils;
import org.dartlang.analysis.server.protocol.CompletionSuggestion;
import org.dartlang.analysis.server.protocol.Element;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -42,7 +42,7 @@ private static Icon findIcon(@NotNull final CompletionSuggestion suggestion) {
final Element element = suggestion.getElement();
if (element != null) {
final String returnType = element.getReturnType();
if (!StringUtils.isEmpty(returnType)) {
if (!StringUtil.isEmpty(returnType)) {
final String name = element.getName();
if (name != null) {
final String declaringType = suggestion.getDeclaringType();
Expand Down
4 changes: 2 additions & 2 deletions flutter-idea/src/io/flutter/inspector/DiagnosticsNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.xdebugger.XSourcePosition;
import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService;
import io.flutter.run.daemon.FlutterApp;
import io.flutter.utils.CustomIconMaker;
import io.flutter.utils.JsonUtils;
import io.flutter.vmService.frame.DartVmServiceValue;
import org.apache.commons.lang3.StringUtils;
import org.dartlang.analysis.server.protocol.HoverInformation;
import org.dartlang.vm.service.element.InstanceRef;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -97,7 +97,7 @@ public boolean equals(Object other) {
@Override
public String toString() {
final String name = getName();
if (StringUtils.isEmpty(name) || !getShowName()) {
if (StringUtil.isEmpty(name) || !getShowName()) {
return getDescription();
}

Expand Down
4 changes: 2 additions & 2 deletions flutter-idea/src/io/flutter/module/FlutterGeneratorPeer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.TextComponentAccessor;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.ui.ComboboxWithBrowseButton;
import com.intellij.ui.DocumentAdapter;
Expand All @@ -30,7 +31,6 @@
import javax.swing.JTextPane;
import javax.swing.event.DocumentEvent;
import javax.swing.text.JTextComponent;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -123,7 +123,7 @@ public boolean validate() {
@Nullable
private ValidationInfo validateSdk() {
final String sdkPath = getSdkComboPath();
if (StringUtils.isEmpty(sdkPath)) {
if (StringUtil.isEmpty(sdkPath)) {
return new ValidationInfo("A Flutter SDK must be specified for project creation.", mySdkPathComboWithBrowse);
}
final String message = FlutterSdkUtil.getErrorMessageIfWrongSdkRootPath(sdkPath);
Expand Down
3 changes: 1 addition & 2 deletions flutter-idea/src/io/flutter/module/FlutterModuleBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import javax.swing.Icon;
import javax.swing.JComponent;

import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -170,7 +169,7 @@ private String validateSettings(FlutterCreateAdditionalSettings settings) {
if (org == null) {
return null;
}
if (StringUtils.endsWith(org, ".")) {
if (StringUtil.endsWith(org, ".")) {
return FlutterBundle.message("npw_invalid_org_error");
}
if (mySettingsFields.shouldIncludePlatforms() && !settings.isSomePlatformSelected()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.xdebugger.XDebugProcess;
import com.intellij.xdebugger.XDebugProcessStarter;
import com.intellij.xdebugger.XDebugSession;
Expand All @@ -47,7 +48,6 @@
import io.flutter.utils.JsonUtils;
import io.flutter.utils.StdoutJsonParser;
import io.flutter.utils.UrlUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -279,7 +279,7 @@ protected VirtualFile findLocalFile(@NotNull final String uri) {

// Verify the returned workspace directory name, we weren't passed a workspace name or if the valid workspace name does not start the
// uri then return the super invocation of this method. This prevents the unknown URI type from being passed to the analysis server.
if (StringUtils.isEmpty(workspaceDirName) || !uri.startsWith(workspaceDirName + ":/")) return super.findLocalFile(uri);
if (StringUtil.isEmpty(workspaceDirName) || !uri.startsWith(workspaceDirName + ":/")) return super.findLocalFile(uri);

final String pathFromWorkspace = uri.substring(workspaceDirName.length() + 1);

Expand Down
4 changes: 2 additions & 2 deletions flutter-idea/src/io/flutter/run/common/TestType.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import com.intellij.icons.AllIcons;
import com.intellij.psi.PsiElement;
import org.apache.commons.lang3.StringUtils;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
Expand Down Expand Up @@ -51,7 +51,7 @@ public Icon getIcon() {
@NotNull
public String getTooltip(@NotNull PsiElement element, @NotNull CommonTestConfigUtils testConfigUtils) {
final String testName = testConfigUtils.findTestName(element);
if (StringUtils.isNotEmpty(testName)) {
if (StringUtil.isNotEmpty(testName)) {
return "Run '" + testName + "'";
}

Expand Down
2 changes: 2 additions & 0 deletions tool/plugin/lib/lint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class LintCommand extends Command<int> {
// See https://github.com/flutter/flutter-intellij/issues/6933
'org.apache.commons.lang.StringUtils',
'org.apache.commons.lang.StringEscapeUtils',
// https://github.com/dart-lang/sdk/issues/39377
'org.apache.commons.lang3.StringUtils',

// Not technically a bad import, but not all IntelliJ platforms provide
// this library.
Expand Down

0 comments on commit 0c045af

Please sign in to comment.