Skip to content

Commit d15559b

Browse files
authored
[CQ] remove inspector/preview deadcode (flutter#8214)
Another deadcode round-up cleaning up unused bits: * orphaned by removed preview support * unused (and stale) observatory integration * inspector cruft * commented out code (dating back 7 years 😬 flutter@6350cf8) In the best case we got a little perf boost by not calculating flutter imports that were being unused 🎉 --- - [x] I’ve reviewed the contributor guide and applied the relevant portions to this PR. <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide]([https://github.com/dart-lang/sdk/blob/main/CONTRIBUTING.md](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Dart contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Java and Kotlin contributions should strive to follow Java and Kotlin best practices ([discussion](flutter#8098)). </details>
1 parent 0fdf15c commit d15559b

File tree

14 files changed

+10
-282
lines changed

14 files changed

+10
-282
lines changed

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.intellij.psi.PsiDirectory;
2323
import com.intellij.psi.PsiElement;
2424
import com.intellij.psi.PsiFile;
25-
import com.intellij.testFramework.LightVirtualFile;
2625
import com.jetbrains.lang.dart.DartFileType;
2726
import com.jetbrains.lang.dart.psi.DartFile;
2827
import io.flutter.jxbrowser.EmbeddedJxBrowser;
@@ -85,16 +84,6 @@ public long getModificationStamp() {
8584
private FlutterUtils() {
8685
}
8786

88-
public static boolean couldContainWidgets(@Nullable Project project, @Nullable VirtualFile file) {
89-
// Skip nulls, temp file used to show things like files downloaded from the VM, non-local files
90-
return file != null &&
91-
project != null &&
92-
!(file instanceof LightVirtualFile) &&
93-
isDartFile(file) &&
94-
file.isInLocalFileSystem() &&
95-
ProjectFileIndex.getInstance(project).isInProject(file);
96-
}
97-
9887
public static boolean isDartFile(@NotNull VirtualFile file) {
9988
return Objects.equals(file.getFileType(), DartFileType.INSTANCE);
10089
}
@@ -427,12 +416,7 @@ protected void addImplicitResolvers() {
427416
return null;
428417
}
429418
}
430-
431-
@Nullable
432-
private static VirtualFile getAndroidProjectDir(VirtualFile dir) {
433-
return (dir.findChild("app") == null) ? null : dir;
434-
}
435-
419+
436420
@Nullable
437421
private static VirtualFile getFlutterManagedAndroidDir(VirtualFile dir) {
438422
final VirtualFile meta = dir.findChild(".metadata");

flutter-idea/src/io/flutter/actions/FlutterRetargetAppAction.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
* context required to execute.
2525
*/
2626
public abstract class FlutterRetargetAppAction extends DumbAwareAction {
27-
public static final String RELOAD_DISPLAY_ID = "Flutter Commands"; //NON-NLS
28-
2927
@NotNull
3028
private final String myActionId;
3129

flutter-idea/src/io/flutter/pub/PubRoot.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -447,21 +447,7 @@ public Module getModule(@NotNull Project project) {
447447
}
448448
return ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(pubspec);
449449
}
450-
451-
/**
452-
* Returns true if the PubRoot is an ancestor of the given file.
453-
*/
454-
public boolean contains(@NotNull VirtualFile file) {
455-
VirtualFile dir = file.getParent();
456-
while (dir != null) {
457-
if (dir.equals(root)) {
458-
return true;
459-
}
460-
dir = dir.getParent();
461-
}
462-
return false;
463-
}
464-
450+
465451
@Override
466452
public String toString() {
467453
return "PubRoot(" + root.getName() + ")";

flutter-idea/src/io/flutter/run/FlutterLaunchMode.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ public static FlutterLaunchMode fromEnv(@NotNull ExecutionEnvironment env) {
3737
this.myCliCommand = cliCommand;
3838
}
3939

40-
public String getCliCommand() {
41-
return myCliCommand;
42-
}
43-
4440
/**
4541
* This mode supports a debug connection (but, doesn't necessarily support breakpoints and debugging).
4642
*/
@@ -51,11 +47,7 @@ public boolean supportsDebugConnection() {
5147
public boolean supportsReload() {
5248
return this == DEBUG;
5349
}
54-
55-
public boolean isProfiling() {
56-
return this == PROFILE;
57-
}
58-
50+
5951
@Override
6052
public String toString() {
6153
return myCliCommand;

flutter-idea/src/io/flutter/run/FlutterPositionMapper.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -277,23 +277,7 @@ private XSourcePosition getSourcePosition(@NotNull final String isolateId, @NotN
277277
String getRemoteSourceRoot() {
278278
return remoteSourceRoot;
279279
}
280-
281-
/**
282-
* Attempt to find a local Dart file corresponding to a script in Observatory.
283-
*/
284-
@Nullable
285-
private VirtualFile findLocalFile(@NotNull ScriptRef scriptRef) {
286-
return findLocalFile(scriptRef.getUri());
287-
}
288-
289-
/**
290-
* Attempt to find a local Dart file corresponding to a script in Observatory.
291-
*/
292-
@Nullable
293-
private VirtualFile findLocalFile(@NotNull Script script) {
294-
return findLocalFile(script.getUri());
295-
}
296-
280+
297281
@Nullable
298282
protected VirtualFile findLocalFile(@NotNull String uri) {
299283
return findLocalFile(uri, null);

flutter-idea/src/io/flutter/run/MainFile.java

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
import com.intellij.openapi.vfs.VirtualFile;
1515
import com.intellij.psi.PsiFile;
1616
import com.intellij.psi.PsiManager;
17-
import com.intellij.psi.util.PsiTreeUtil;
1817
import com.jetbrains.lang.dart.psi.DartFile;
19-
import com.jetbrains.lang.dart.psi.DartImportStatement;
2018
import com.jetbrains.lang.dart.util.DartResolveUtil;
2119
import io.flutter.FlutterBundle;
2220
import io.flutter.FlutterUtils;
@@ -26,9 +24,6 @@
2624
import org.jetbrains.annotations.NotNull;
2725
import org.jetbrains.annotations.Nullable;
2826

29-
import java.util.Arrays;
30-
import java.util.stream.Stream;
31-
3227
/**
3328
* The location of a Dart file containing a main() method for launching a Flutter app.
3429
* <p>
@@ -42,12 +37,9 @@ public class MainFile {
4237
@NotNull
4338
private final VirtualFile appDir;
4439

45-
private final boolean flutterImports;
46-
47-
private MainFile(@NotNull VirtualFile file, @NotNull VirtualFile appDir, boolean flutterImports) {
40+
private MainFile(@NotNull VirtualFile file, @NotNull VirtualFile appDir) {
4841
this.file = file;
4942
this.appDir = appDir;
50-
this.flutterImports = flutterImports;
5143
}
5244

5345
/**
@@ -66,13 +58,6 @@ public VirtualFile getAppDir() {
6658
return appDir;
6759
}
6860

69-
/**
70-
* Returns true if the file has any direct flutter imports.
71-
*/
72-
public boolean hasFlutterImports() {
73-
return flutterImports;
74-
}
75-
7661
/**
7762
* Verifies that the given path points to an entrypoint file within a Flutter app.
7863
* <p>
@@ -118,9 +103,7 @@ public static MainFile.Result verify(@Nullable String path, @Nullable Project pr
118103
return error(FlutterBundle.message("entrypoint.not.in.app.dir"));
119104
}
120105

121-
final boolean hasFlutterImports = findImportUrls(dart).anyMatch((url) -> url.startsWith("package:flutter/"));
122-
123-
return new MainFile.Result(new MainFile(file, dir, hasFlutterImports), null);
106+
return new MainFile.Result(new MainFile(file, dir), null);
124107
}
125108

126109
@Nullable
@@ -153,17 +136,6 @@ private static boolean inProject(@Nullable VirtualFile file, @NotNull Project pr
153136
return file != null && BaseProjectDirectories.getInstance(project).contains(file);
154137
}
155138

156-
/**
157-
* Returns the import URL's in a Dart file.
158-
*/
159-
@NotNull
160-
private static Stream<String> findImportUrls(@NotNull DartFile file) {
161-
final DartImportStatement[] imports = PsiTreeUtil.getChildrenOfType(file, DartImportStatement.class);
162-
if (imports == null) return Stream.empty();
163-
164-
return Arrays.stream(imports).map(DartImportStatement::getUriString);
165-
}
166-
167139
private static MainFile.Result error(@NotNull String message) {
168140
return new MainFile.Result(null, message);
169141
}

flutter-idea/src/io/flutter/run/daemon/FlutterApp.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public class FlutterApp implements Disposable {
6565
private static final Key<FlutterApp> FLUTTER_APP_KEY = new Key<>("FLUTTER_APP_KEY");
6666

6767
private final @NotNull Project myProject;
68-
private final @Nullable Module myModule;
6968
private final @NotNull RunMode myMode;
7069
private final @NotNull FlutterDevice myDevice;
7170
private final @NotNull ProcessHandler myProcessHandler;
@@ -90,8 +89,6 @@ public class FlutterApp implements Disposable {
9089
private int userReloadCount;
9190
private int restartCount;
9291

93-
private long maxFileTimestamp;
94-
9592
/**
9693
* Non-null when the debugger is paused.
9794
*/
@@ -117,23 +114,20 @@ public static FlutterApp fromEnv(@NotNull ExecutionEnvironment env) {
117114
}
118115

119116
FlutterApp(@NotNull Project project,
120-
@Nullable Module module,
121117
@NotNull RunMode mode,
122118
@NotNull FlutterDevice device,
123119
@NotNull ProcessHandler processHandler,
124120
@NotNull ExecutionEnvironment executionEnvironment,
125121
@NotNull DaemonApi daemonApi,
126122
@NotNull GeneralCommandLine command) {
127123
myProject = project;
128-
myModule = module;
129124
myMode = mode;
130125
myDevice = device;
131126
myProcessHandler = processHandler;
132127
myProcessHandler.putUserData(FLUTTER_APP_KEY, this);
133128
myExecutionEnvironment = executionEnvironment;
134129
myDaemonApi = daemonApi;
135130
myCommand = command;
136-
maxFileTimestamp = System.currentTimeMillis();
137131
myConnector = new ObservatoryConnector() {
138132
@Override
139133
public @Nullable
@@ -242,7 +236,7 @@ public static FlutterApp start(@NotNull ExecutionEnvironment env,
242236
Disposer.register(FlutterDartAnalysisServer.getInstance(project), process::destroyProcess);
243237

244238
final DaemonApi api = new DaemonApi(process);
245-
final FlutterApp app = new FlutterApp(project, module, mode, device, process, env, api, command);
239+
final FlutterApp app = new FlutterApp(project, mode, device, process, env, api, command);
246240

247241
process.addProcessListener(new ProcessAdapter() {
248242
@Override
@@ -338,7 +332,6 @@ public CompletableFuture<DaemonApi.RestartResult> performRestartApp(@NotNull Str
338332

339333
LocalHistory.getInstance().putSystemLabel(getProject(), "Flutter hot restart");
340334

341-
maxFileTimestamp = System.currentTimeMillis();
342335
changeState(State.RESTARTING);
343336

344337
final CompletableFuture<DaemonApi.RestartResult> future =
@@ -403,7 +396,6 @@ public CompletableFuture<DaemonApi.RestartResult> performHotReload(boolean pause
403396

404397
LocalHistory.getInstance().putSystemLabel(getProject(), "hot reload #" + userReloadCount);
405398

406-
maxFileTimestamp = System.currentTimeMillis();
407399
changeState(State.RELOADING);
408400

409401
final CompletableFuture<DaemonApi.RestartResult> future =

flutter-idea/src/io/flutter/sdk/FlutterSdk.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
import static java.util.Arrays.asList;
5454

5555
public class FlutterSdk {
56-
public static final @NotNull String FLUTTER_SDK_GLOBAL_LIB_NAME = "Flutter SDK";
57-
5856
public static final @NotNull String DART_SDK_SUFFIX = "/bin/cache/dart-sdk";
5957
public static final @NotNull String LINUX_DART_SUFFIX = "/google-dartlang";
6058
public static final @NotNull String LOCAL_DART_SUFFIX = "/google-dartlang-local";
@@ -368,15 +366,6 @@ else if (flutterLaunchMode == FlutterLaunchMode.RELEASE) {
368366
return new FlutterCommand(this, root.getRoot(), FlutterCommand.Type.ATTACH, args.toArray(new String[]{ }));
369367
}
370368

371-
@NotNull
372-
public FlutterCommand flutterRunOnTester(@NotNull PubRoot root, @NotNull String mainPath) {
373-
final List<String> args = new ArrayList<>();
374-
args.add("--machine");
375-
args.add("--device-id=flutter-tester");
376-
args.add(mainPath);
377-
return new FlutterCommand(this, root.getRoot(), FlutterCommand.Type.RUN, args.toArray(new String[]{ }));
378-
}
379-
380369
@NotNull
381370
public FlutterCommand flutterTest(@NotNull PubRoot root, @NotNull VirtualFile fileOrDir, @Nullable String testNameSubstring,
382371
@NotNull RunMode mode, @Nullable String additionalArgs, TestFields.Scope scope, boolean useRegexp) {

flutter-idea/src/io/flutter/sdk/FlutterSdkChannel.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,7 @@ public static FlutterSdkChannel fromText(@NotNull String text) {
4949
private FlutterSdkChannel(@NotNull ID channel) {
5050
this.channel = channel;
5151
}
52-
53-
@NotNull
54-
public ID getID() {
55-
return channel;
56-
}
57-
52+
5853
public String toString() {
5954
return "channel " + channel;
6055
}

0 commit comments

Comments
 (0)