Skip to content

Commit aeffce2

Browse files
authored
Remove unused code, mostly from the utils directory (flutter#7704)
1 parent a53f798 commit aeffce2

File tree

12 files changed

+0
-421
lines changed

12 files changed

+0
-421
lines changed

flutter-idea/src/io/flutter/FlutterUtils.java

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,6 @@ public long getModificationStamp() {
9595
private FlutterUtils() {
9696
}
9797

98-
/**
99-
* This method exists for compatibility with older IntelliJ API versions.
100-
* <p>
101-
* `Application.invokeAndWait(Runnable)` doesn't exist pre 2016.3.
102-
*/
103-
public static void invokeAndWait(@NotNull Runnable runnable) throws ProcessCanceledException {
104-
ApplicationManager.getApplication().invokeAndWait(
105-
runnable,
106-
ModalityState.defaultModalityState());
107-
}
108-
109-
public static boolean isFlutteryFile(@NotNull VirtualFile file) {
110-
return isDartFile(file) || PubRoot.isPubspec(file);
111-
}
112-
11398
public static boolean couldContainWidgets(@Nullable Project project, @Nullable VirtualFile file) {
11499
// Skip nulls, temp file used to show things like files downloaded from the VM, non-local files
115100
return file != null &&
@@ -155,14 +140,6 @@ public static void warn(@NotNull Logger logger, @NotNull String message, @NotNul
155140
logger.warn(message, t);
156141
}
157142

158-
private static int getBaselineVersion() {
159-
final ApplicationInfo appInfo = ApplicationInfo.getInstance();
160-
if (appInfo != null) {
161-
return appInfo.getBuild().getBaselineVersion();
162-
}
163-
return -1;
164-
}
165-
166143
public static void disableGradleProjectMigrationNotification(@NotNull Project project) {
167144
final String showMigrateToGradlePopup = "show.migrate.to.gradle.popup";
168145
final PropertiesComponent properties = PropertiesComponent.getInstance(project);
@@ -172,10 +149,6 @@ public static void disableGradleProjectMigrationNotification(@NotNull Project pr
172149
}
173150
}
174151

175-
public static boolean exists(@Nullable VirtualFile file) {
176-
return file != null && file.exists();
177-
}
178-
179152
/**
180153
* Test if the given element is contained in a module with a pub root that declares a flutter dependency.
181154
*/
@@ -356,41 +329,13 @@ public static boolean isXcodeWorkspaceFileName(@NotNull String name) {
356329
return name.endsWith(".xcworkspace");
357330
}
358331

359-
/**
360-
* Checks whether the given commandline executes cleanly.
361-
*
362-
* @param cmd the command
363-
* @return true if the command runs cleanly
364-
*/
365-
public static boolean runsCleanly(@NotNull GeneralCommandLine cmd) {
366-
try {
367-
return ExecUtil.execAndGetOutput(cmd).getExitCode() == 0;
368-
}
369-
catch (ExecutionException e) {
370-
return false;
371-
}
372-
}
373-
374332
@NotNull
375333
public static PluginId getPluginId() {
376334
final PluginId pluginId = PluginId.findId("io.flutter", "");
377335
assert pluginId != null;
378336
return pluginId;
379337
}
380338

381-
/**
382-
* Given some plugin id, this method returns the {@link IdeaPluginDescriptor}, or null if the plugin is not installed.
383-
*/
384-
@Nullable
385-
public static IdeaPluginDescriptor getPluginDescriptor(@NotNull String pluginId) {
386-
for (IdeaPluginDescriptor descriptor : PluginManagerCore.getPlugins()) {
387-
if (descriptor.getPluginId().getIdString().equals(pluginId)) {
388-
return descriptor;
389-
}
390-
}
391-
return null;
392-
}
393-
394339
/**
395340
* Returns a structured object with information about the Flutter properties of the given
396341
* pubspec file.
@@ -493,36 +438,6 @@ protected void addImplicitResolvers() {
493438
}
494439
}
495440

496-
public static boolean isAndroidxProject(@NotNull Project project) {
497-
@SystemIndependent final String basePath = project.getBasePath();
498-
assert basePath != null;
499-
final VirtualFile projectDir = LocalFileSystem.getInstance().findFileByPath(basePath);
500-
assert projectDir != null;
501-
VirtualFile androidDir = getFlutterManagedAndroidDir(projectDir);
502-
if (androidDir == null) {
503-
androidDir = getAndroidProjectDir(projectDir);
504-
if (androidDir == null) {
505-
return false;
506-
}
507-
}
508-
final VirtualFile propFile = androidDir.findChild("gradle.properties");
509-
if (propFile == null) {
510-
return false;
511-
}
512-
final Properties properties = new Properties();
513-
try {
514-
properties.load(new InputStreamReader(propFile.getInputStream(), Charsets.UTF_8));
515-
}
516-
catch (IOException ex) {
517-
return false;
518-
}
519-
final String value = properties.getProperty("android.useAndroidX");
520-
if (value != null) {
521-
return Boolean.parseBoolean(value);
522-
}
523-
return false;
524-
}
525-
526441
@Nullable
527442
private static VirtualFile getAndroidProjectDir(VirtualFile dir) {
528443
return (dir.findChild("app") == null) ? null : dir;

flutter-idea/src/io/flutter/dart/DartPlugin.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,16 @@
66
package io.flutter.dart;
77

88
import com.intellij.execution.configurations.ConfigurationType;
9-
import com.intellij.ide.plugins.IdeaPluginDescriptor;
10-
import com.intellij.ide.plugins.PluginManagerCore;
11-
import com.intellij.openapi.extensions.PluginId;
129
import com.intellij.openapi.module.Module;
1310
import com.intellij.openapi.project.Project;
1411
import com.intellij.openapi.util.Version;
1512
import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService;
1613
import com.jetbrains.lang.dart.ide.actions.DartPubActionBase;
1714
import com.jetbrains.lang.dart.sdk.DartSdk;
1815
import com.jetbrains.lang.dart.sdk.DartSdkLibUtil;
19-
import com.jetbrains.lang.dart.sdk.DartSdkUpdateOption;
20-
import com.jetbrains.lang.dart.sdk.DartSdkUtil;
2116
import org.jetbrains.annotations.NotNull;
2217
import org.jetbrains.annotations.Nullable;
2318

24-
import java.util.Collection;
2519
import java.util.Objects;
2620

2721
/**
@@ -38,8 +32,6 @@ public class DartPlugin {
3832
@NotNull
3933
private static final DartPlugin INSTANCE = new DartPlugin();
4034

41-
private Version myVersion;
42-
4335
@NotNull
4436
public static DartPlugin getInstance() {
4537
return INSTANCE;
@@ -62,14 +54,6 @@ public static void ensureDartSdkConfigured(@NotNull Project project, @NotNull St
6254
DartSdkLibUtil.ensureDartSdkConfigured(project, sdkHomePath);
6355
}
6456

65-
public static void disableDartSdk(@NotNull Collection<Module> modules) {
66-
DartSdkLibUtil.disableDartSdk(modules);
67-
}
68-
69-
public static boolean isDartSdkHome(@Nullable String path) {
70-
return DartSdkUtil.isDartSdkHome(path);
71-
}
72-
7357
public static boolean isPubActionInProgress() {
7458
return DartPubActionBase.isInProgress();
7559
}
@@ -86,26 +70,6 @@ public static boolean isDartTestConfiguration(@NotNull ConfigurationType type) {
8670
return type.getId().equals("DartTestRunConfigurationType");
8771
}
8872

89-
public static DartSdkUpdateOption doCheckForUpdates() {
90-
return DartSdkUpdateOption.getDartSdkUpdateOption();
91-
}
92-
93-
public static void setCheckForUpdates(@NotNull DartSdkUpdateOption sdkUpdateOption) {
94-
DartSdkUpdateOption.setDartSdkUpdateOption(sdkUpdateOption);
95-
}
96-
97-
/**
98-
* Return the {@link Version} of the currently installed Dart Plugin.
99-
*/
100-
public Version getVersion() {
101-
if (myVersion == null) {
102-
final IdeaPluginDescriptor descriptor = PluginManagerCore.getPlugin(PluginId.getId("Dart"));
103-
assert (descriptor != null);
104-
myVersion = Objects.requireNonNull(Version.parseVersion(Objects.requireNonNull(descriptor.getVersion())));
105-
}
106-
return myVersion;
107-
}
108-
10973
/**
11074
* Return the {@link DartAnalysisServerService} instance for the passed {@link Project}.
11175
*/

flutter-idea/src/io/flutter/dart/DartPsiUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public static PsiElement getNamedArgumentExpression(@NotNull DartArguments argum
7878
assert namedArgument != null;
7979
final DartExpression nameExpression = namedArgument.getParameterReferenceExpression();
8080
assert nameExpression != null;
81-
final PsiElement childId = nameExpression.getFirstChild();
8281
final PsiElement child = nameExpression.getFirstChild();
8382
if (name.equals(child != null ? child.getText() : "")) {
8483
return namedArgument.getExpression();

flutter-idea/src/io/flutter/editor/ActiveEditorsOutlineService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ private void updateActiveEditors() {
123123

124124
// Remove obsolete outline listeners.
125125
final List<String> obsoletePaths = new ArrayList<>();
126-
FlutterDartAnalysisServer analysisServer = getAnalysisServer();
127126

128127
synchronized (outlineListeners) {
129128
for (final String path : outlineListeners.keySet()) {

flutter-idea/src/io/flutter/utils/FileUtils.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,6 @@ public boolean deleteFile(String path) {
5555
}
5656
return true;
5757
}
58-
59-
public void loadClass(ClassLoader classLoader, String path) throws Exception {
60-
final UrlClassLoader urlClassLoader = (UrlClassLoader) classLoader;
61-
62-
final File file = new File(path);
63-
if (!file.exists()) {
64-
throw new Exception("File does not exist: " + file.getAbsolutePath());
65-
}
66-
67-
final URL url = file.toURI().toURL();
68-
urlClassLoader.addURL(url);
69-
}
70-
7158
/**
7259
* Loads a list of file paths with a class loader.
7360
*

flutter-idea/src/io/flutter/utils/HtmlBuilder.java

Lines changed: 0 additions & 54 deletions
This file was deleted.

flutter-idea/src/io/flutter/utils/IconPreviewGenerator.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -161,36 +161,6 @@ private void drawGlyph(String codepoint, Graphics2D graphics, FontRenderContext
161161
graphics.drawString(codepoint, x0, y0);
162162
}
163163

164-
@Nullable
165-
public static VirtualFile findAssetMapFor(@NotNull DartComponent dartClass) {
166-
final ASTNode node = dartClass.getNode();
167-
if (DartTokenTypes.CLASS_DEFINITION != node.getElementType()) {
168-
return null;
169-
}
170-
final DartFile psiElement = (DartFile)node.getPsi().getParent();
171-
final VirtualFile file = psiElement.getVirtualFile();
172-
VirtualFile map = findAssetMapIn(file.getParent());
173-
if (map != null) {
174-
return map;
175-
}
176-
final PsiElement identifier = dartClass.getNameIdentifier();
177-
if (identifier == null) {
178-
return null;
179-
}
180-
final String className = AstBufferUtil.getTextSkippingWhitespaceComments(identifier.getNode());
181-
final URL resource = IconPreviewGenerator.class.getResource("/iconAssetMaps/" + className + "/asset_map.yaml");
182-
if (resource == null) {
183-
return null;
184-
}
185-
try {
186-
final URI uri = resource.toURI();
187-
return LocalFileSystem.getInstance().findFileByNioFile(Paths.get(uri));
188-
}
189-
catch (URISyntaxException e) {
190-
return null;
191-
}
192-
}
193-
194164
@Nullable
195165
public static VirtualFile findAssetMapIn(@NotNull VirtualFile dartClass) {
196166
VirtualFile dir = dartClass.getParent();

flutter-idea/src/io/flutter/utils/JsonUtils.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,6 @@ public static int getIntMember(@NotNull JsonObject json, @NotNull String memberN
3939
return value instanceof JsonNull ? -1 : value.getAsInt();
4040
}
4141

42-
@NotNull
43-
public static List<String> getValues(@NotNull JsonObject json, @NotNull String member) {
44-
if (!json.has(member)) {
45-
return Collections.emptyList();
46-
}
47-
48-
final JsonArray rawValues = json.getAsJsonArray(member);
49-
final ArrayList<String> values = new ArrayList<>(rawValues.size());
50-
rawValues.forEach(element -> values.add(element.getAsString()));
51-
52-
return values;
53-
}
54-
5542
// JsonObject.keySet() is defined in 2.8.6 but not 2.7.
5643
// The 2020.3 version of Android Studio includes both, and 2.7 is first on the class path.
5744
public static Set<String> getKeySet(JsonObject obj) {
@@ -63,10 +50,6 @@ public static Set<String> getKeySet(JsonObject obj) {
6350
return strings;
6451
}
6552

66-
public static boolean hasJsonData(@Nullable String data) {
67-
return StringUtils.isNotEmpty(data) && !Objects.equals(data, "null");
68-
}
69-
7053
/**
7154
* Parses the specified JSON string into a JsonElement.
7255
*/

0 commit comments

Comments
 (0)