Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of all gnu.trove.* deps from the Flutter plugin #7789

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.jetbrains.lang.dart.psi.impl.DartCallExpressionImpl;
import com.jetbrains.lang.dart.util.DartPsiImplUtil;
import com.jetbrains.lang.dart.util.DartResolveUtil;
import gnu.trove.THashSet;
import info.debatty.java.stringsimilarity.JaroWinkler;
import io.flutter.FlutterBundle;
import io.flutter.sdk.FlutterSdk;
Expand Down Expand Up @@ -62,9 +61,9 @@ public class FlutterIconLineMarkerProvider extends LineMarkerProviderDescriptor

public static void initialize() {
KnownPaths.clear();
KnownPaths.put("Icons", new THashSet<>(Collections.singleton("packages/flutter/lib/src/material")));
KnownPaths.put("IconData", new THashSet<>(Collections.singleton("packages/flutter/lib/src/widgets")));
KnownPaths.put("CupertinoIcons", new THashSet<>(Collections.singleton("packages/flutter/lib/src/cupertino")));
KnownPaths.put("Icons", new HashSet<>(Collections.singleton("packages/flutter/lib/src/material")));
KnownPaths.put("IconData", new HashSet<>(Collections.singleton("packages/flutter/lib/src/widgets")));
KnownPaths.put("CupertinoIcons", new HashSet<>(Collections.singleton("packages/flutter/lib/src/cupertino")));
BuiltInPaths.clear();
BuiltInPaths.put("Icons", MaterialRelativeIconsPath);
BuiltInPaths.put("IconData", MaterialRelativeIconsPath);
Expand Down
18 changes: 8 additions & 10 deletions flutter-idea/src/io/flutter/font/FontPreviewProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import com.jetbrains.lang.dart.resolve.ClassNameScopeProcessor;
import com.jetbrains.lang.dart.resolve.DartPsiScopeProcessor;
import com.jetbrains.lang.dart.util.DartResolveUtil;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
import io.flutter.FlutterBundle;
import io.flutter.editor.FlutterIconLineMarkerProvider;
import io.flutter.settings.FlutterSettings;
Expand All @@ -55,13 +53,13 @@
public class FontPreviewProcessor {

public static final String PACKAGE_SEPARATORS = "[,\r\n]";
public static final Map<String, String> UNSUPPORTED_PACKAGES = new THashMap<>();
public static final Map<String, String> UNSUPPORTED_PACKAGES = new HashMap<>();

// If there are triple quotes around a package URL they won't be recognized.
private static final Pattern EXPORT_STATEMENT_PATTERN = Pattern.compile("^\\s*export\\s+[\"']([-_. $A-Za-z0-9/]+\\.dart)[\"'].*");
private static final Pattern IMPORT_STATEMENT_PATTERN = Pattern.compile("^\\s*import\\s+[\"']([-_. $A-Za-z0-9/]+\\.dart)[\"'].*");
private static final Map<String, Set<String>> ANALYZED_PROJECT_FILES = new THashMap<>();
private static final Map<String, WorkItem> WORK_ITEMS = new THashMap<>();
private static final Map<String, Set<String>> ANALYZED_PROJECT_FILES = new HashMap<>();
private static final Map<String, WorkItem> WORK_ITEMS = new HashMap<>();
private static Logger LOG = Logger.getInstance(FontPreviewProcessor.class);

static {
Expand All @@ -86,7 +84,7 @@ public void generate(@NotNull Project project) {
}
LOG = FlutterSettings.getInstance().isVerboseLogging() ? Logger.getInstance(FontPreviewProcessor.class) : null;
log("Analyzing project ", project.getName());
ANALYZED_PROJECT_FILES.put(project.getBasePath(), new THashSet<>());
ANALYZED_PROJECT_FILES.put(project.getBasePath(), new HashSet<>());
ProjectManager.getInstance().addProjectManagerListener(project, new ProjectManagerListener() {
@Override
public void projectClosed(@NotNull Project project) {
Expand Down Expand Up @@ -257,12 +255,12 @@ private void analyzeNextFile(@NotNull Project project, @NotNull WorkItem item) {
log("Cannot get PSI file for ", file.getName());
return;
}
final Set<DartComponentName> classNames = new THashSet<>();
final Set<DartComponentName> classNames = new HashSet<>();
final DartPsiScopeProcessor processor = new ClassNameScopeProcessor(classNames);
final boolean success = DumbService.getInstance(project).runReadActionInSmartMode(() -> {
final boolean result = DartResolveUtil.processTopLevelDeclarations(psiFile, processor, file, null);
if (result) {
final Set<DartComponentName> keep = new THashSet<>();
final Set<DartComponentName> keep = new HashSet<>();
for (DartComponentName name : classNames) {
if (file.equals(name.getContainingFile().getVirtualFile())) {
keep.add(name);
Expand Down Expand Up @@ -299,7 +297,7 @@ private void analyzeNextClass(@NotNull Project project, @NotNull WorkItem item)
log("Adding ", name, " -> ", path);
final Set<String> knownPaths = KnownPaths.get(name);
if (knownPaths == null) {
KnownPaths.put(name, new THashSet<>(Collections.singleton(path)));
KnownPaths.put(name, new HashSet<>(Collections.singleton(path)));
}
else {
knownPaths.add(path);
Expand Down Expand Up @@ -460,7 +458,7 @@ static class WorkItem {
final Queue<FileInfo> filesToRewrite = new LinkedList<>();
final Queue<ClassInfo> classesToAnalyze = new LinkedList<>();
final Queue<FileInfo> filesToCheck = new LinkedList<>();
final Map<String, PathInfo> filesWithNoClasses = new THashMap<>();
final Map<String, PathInfo> filesWithNoClasses = new HashMap<>();
final String projectPath;
boolean isCancelled = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.jetbrains.lang.dart.psi.DartFile;
import gnu.trove.THashSet;
import io.flutter.FlutterBundle;
import io.flutter.FlutterUtils;
import io.flutter.bazel.WorkspaceCache;
Expand All @@ -27,10 +26,11 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashSet;
import java.util.Set;

public class FlutterDependencyInspection extends LocalInspectionTool {
private final Set<String> myIgnoredPubspecPaths = new THashSet<>(); // remember for the current session only, do not serialize
private final Set<String> myIgnoredPubspecPaths = new HashSet<>(); // remember for the current session only, do not serialize

@Nullable
@Override
Expand Down
26 changes: 13 additions & 13 deletions flutter-idea/src/io/flutter/perf/FlutterWidgetPerf.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package io.flutter.perf;

import com.android.tools.idea.io.netty.util.collection.IntObjectHashMap;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.LinkedListMultimap;
Expand All @@ -23,7 +24,6 @@
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ui.EdtInvocationManager;
import gnu.trove.TIntObjectHashMap;
import io.flutter.utils.AsyncUtils;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -52,7 +52,7 @@ public class FlutterWidgetPerf implements Disposable, WidgetPerfListener {
public static final long IDLE_DELAY_MILISECONDS = 400;

static class StatsForReportKind {
final TIntObjectHashMap<SlidingWindowStats> data = new TIntObjectHashMap<>();
final IntObjectHashMap<SlidingWindowStats> data = new IntObjectHashMap<>();
private int lastStartTime = -1;
private int lastNonEmptyReportTime = -1;
}
Expand All @@ -73,7 +73,7 @@ static class StatsForReportKind {
* Note: any access of editorDecorations contents must happen on the UI thread.
*/
private final Map<TextEditor, EditorPerfModel> editorDecorations = new HashMap<>();
private final TIntObjectHashMap<Location> knownLocationIds = new TIntObjectHashMap<>();
private final IntObjectHashMap<Location> knownLocationIds = new IntObjectHashMap<>();
private final SetMultimap<String, Location> locationsPerFile = HashMultimap.create();
private final Map<PerfReportKind, StatsForReportKind> stats = new HashMap<>();

Expand Down Expand Up @@ -172,9 +172,10 @@ public void onWidgetPerfEvent(PerfReportKind kind, JsonObject json) {
if (statsForReportKind.lastStartTime > startTimeMilis) {
// We went backwards in time. There must have been a hot restart so
// clear all old stats.
statsForReportKind.data.forEachValue((SlidingWindowStats entry) -> {
entry.clear();
return true;
statsForReportKind.data.forEach((key,entry) -> {
if(entry != null) {
entry.clear();
}
});
}
statsForReportKind.lastStartTime = startTimeMilis;
Expand Down Expand Up @@ -296,9 +297,10 @@ else if (json.has("newLocations")) {
public void onNavigation() {
synchronized (this) {
for (StatsForReportKind statsForKind : stats.values()) {
statsForKind.data.forEachValue((SlidingWindowStats entry) -> {
entry.onNavigation();
return true;
statsForKind.data.forEach((key, entry) -> {
if (entry != null) {
entry.onNavigation();
}
});
}
}
Expand Down Expand Up @@ -417,7 +419,7 @@ private FilePerfInfo buildSummaryStats(TextEditor fileEditor) {
if (forKind == null) {
continue;
}
final TIntObjectHashMap<SlidingWindowStats> data = forKind.data;
final IntObjectHashMap<SlidingWindowStats> data = forKind.data;
for (Location location : locationsPerFile.get(path)) {
final SlidingWindowStats entry = data.get(location.id);
if (entry == null) {
Expand Down Expand Up @@ -579,7 +581,7 @@ public ArrayList<SlidingWindowStatsSummary> getStatsForMetric(ArrayList<PerfMetr
final StatsForReportKind forKind = stats.get(kind);
if (forKind != null) {
final int time = forKind.lastNonEmptyReportTime;
forKind.data.forEachEntry((int locationId, SlidingWindowStats stats) -> {
forKind.data.forEach((locationId, stats) -> {
for (PerfMetric metric : metrics) {
if (stats.getValue(metric, time) > 0) {
final Location location = knownLocationIds.get(locationId);
Expand All @@ -599,10 +601,8 @@ public ArrayList<SlidingWindowStatsSummary> getStatsForMetric(ArrayList<PerfMetr
location
));
}
return true;
}
}
return true;
});
}
}
Expand Down
16 changes: 8 additions & 8 deletions flutter-idea/src/io/flutter/performance/WidgetPerfTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.intellij.util.PathUtil;
import com.intellij.util.ui.ColumnInfo;
import com.intellij.xdebugger.XSourcePosition;
import gnu.trove.TIntArrayList;
import io.flutter.inspector.InspectorActions;
import io.flutter.perf.*;
import io.flutter.run.daemon.FlutterApp;
Expand Down Expand Up @@ -286,8 +285,8 @@ public void showStats(ArrayList<SlidingWindowStatsSummary> entries) {
}
final boolean previouslyEmpty = root.getChildCount() == 0;
int childIndex = 0;
final TIntArrayList indicesChanged = new TIntArrayList();
final TIntArrayList indicesInserted = new TIntArrayList();
final ArrayList<Integer> indicesChanged = new ArrayList();
final ArrayList<Integer> indicesInserted = new ArrayList();
for (SlidingWindowStatsSummary entry : entries) {
if (entry.getLocation().equals(lastSelectedLocation)) {
selectionIndex = childIndex;
Expand All @@ -308,8 +307,8 @@ public void showStats(ArrayList<SlidingWindowStatsSummary> entries) {
childIndex++;
}
final int endChildIndex = childIndex;
final ArrayList<TreeNode> nodesRemoved = new ArrayList<>();
final TIntArrayList indicesRemoved = new TIntArrayList();
final ArrayList<TreeNode> nodesRemoved = new ArrayList();
final ArrayList<Integer> indicesRemoved = new ArrayList();
// Gather nodes to remove.
for (int j = endChildIndex; j < root.getChildCount(); j++) {
nodesRemoved.add(root.getChildAt(j));
Expand All @@ -322,20 +321,21 @@ public void showStats(ArrayList<SlidingWindowStatsSummary> entries) {
root.remove(lastChild);
}

assert(model != null);
if (previouslyEmpty) {
// TODO(jacobr): I'm not clear why this event is needed in this case.
model.nodeStructureChanged(root);
}
else {
// Report events for all the changes made to the table.
if (!indicesChanged.isEmpty()) {
model.nodesChanged(root, indicesChanged.toNativeArray());
model.nodesChanged(root, indicesChanged.stream().mapToInt(i -> i).toArray());//.intStream().toArray());
}
if (!indicesInserted.isEmpty()) {
model.nodesWereInserted(root, indicesInserted.toNativeArray());
model.nodesWereInserted(root, indicesInserted.stream().mapToInt(i -> i).toArray());
}
if (!indicesRemoved.isEmpty()) {
model.nodesWereRemoved(root, indicesRemoved.toNativeArray(), nodesRemoved.toArray());
model.nodesWereRemoved(root, indicesRemoved.stream().mapToInt(i -> i).toArray(), nodesRemoved.toArray());
}
}

Expand Down
8 changes: 2 additions & 6 deletions flutter-idea/src/io/flutter/run/FlutterPositionMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService;
import com.jetbrains.lang.dart.util.DartResolveUtil;
import com.jetbrains.lang.dart.util.DartUrlResolver;
import gnu.trove.THashMap;
import io.flutter.FlutterInitializer;
import io.flutter.FlutterUtils;
import io.flutter.analytics.Analytics;
Expand All @@ -36,10 +35,7 @@
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -104,7 +100,7 @@ public class FlutterPositionMapper implements DartVmServiceDebugProcess.Position
/**
* A cache containing each file version downloaded from Observatory. The key is an isolate id.
*/
private final Map<String, ObservatoryFile.Cache> fileCache = new THashMap<>();
private final Map<String, ObservatoryFile.Cache> fileCache = new HashMap<>();

public FlutterPositionMapper(@NotNull Project project,
@NotNull VirtualFile sourceRoot,
Expand Down
12 changes: 6 additions & 6 deletions flutter-idea/src/io/flutter/run/ObservatoryFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
*/
package io.flutter.run;

import com.android.tools.idea.io.netty.util.collection.IntObjectHashMap;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.PathUtil;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.XSourcePosition;
import com.jetbrains.lang.dart.DartFileType;
import gnu.trove.THashMap;
import gnu.trove.TIntObjectHashMap;
import io.flutter.vmService.DartVmServiceDebugProcess;
import org.dartlang.vm.service.element.Script;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand All @@ -36,7 +36,7 @@ class ObservatoryFile {
* Maps an observatory token id to its line and column.
*/
@Nullable
private final TIntObjectHashMap<Position> positionMap;
private final IntObjectHashMap<Position> positionMap;

/**
* User-visible source code downloaded from Observatory.
Expand Down Expand Up @@ -92,8 +92,8 @@ XSourcePosition createPosition(@Nullable VirtualFile local, int tokenPos) {
* <p>See <a href="https://github.com/dart-lang/vm_service_drivers/blob/master/dart/tool/service.md#scrip">docs</a>.
*/
@NotNull
private static TIntObjectHashMap<Position> createPositionMap(@NotNull final List<List<Integer>> table) {
final TIntObjectHashMap<Position> result = new TIntObjectHashMap<>();
private static IntObjectHashMap<Position> createPositionMap(@NotNull final List<List<Integer>> table) {
final IntObjectHashMap<Position> result = new IntObjectHashMap<>();

for (List<Integer> line : table) {
// Each line consists of a line number followed by (tokenId, columnNumber) pairs.
Expand Down Expand Up @@ -140,7 +140,7 @@ static class Cache {
* A cache containing each file downloaded from Observatory. The key is a script id.
* Each version of a file is stored as a separate entry.
*/
private final Map<String, ObservatoryFile> versions = new THashMap<>();
private final Map<String, ObservatoryFile> versions = new HashMap<>();

Cache(@NotNull String isolateId, @NotNull DartVmServiceDebugProcess.ScriptProvider provider) {
this.isolateId = isolateId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.intellij.util.PathUtil;
import com.jetbrains.lang.dart.ide.runner.util.DartTestLocationProvider;
import com.jetbrains.lang.dart.util.DartUrlResolver;
import gnu.trove.TIntLongHashMap;
import io.flutter.utils.JsonUtils;
import jetbrains.buildServer.messages.serviceMessages.ServiceMessageVisitor;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -94,7 +93,7 @@ public class DartTestEventsConverterZ extends OutputToGeneralTestEventsConverter
private String myLocation;
private Key myCurrentOutputType;
private ServiceMessageVisitor myCurrentVisitor;
private final TIntLongHashMap myTestIdToTimestamp;
private final HashMap myTestIdToTimestamp;
private final Map<Integer, Test> myTestData;
private final Map<Integer, Group> myGroupData;
private final Map<Integer, Suite> mySuiteData;
Expand All @@ -105,7 +104,7 @@ public DartTestEventsConverterZ(@NotNull final String testFrameworkName,
@NotNull final DartUrlResolver urlResolver) {
super(testFrameworkName, consoleProperties);
myUrlResolver = urlResolver;
myTestIdToTimestamp = new TIntLongHashMap();
myTestIdToTimestamp = new HashMap();
myTestData = new HashMap<>();
myGroupData = new HashMap<>();
mySuiteData = new HashMap<>();
Expand Down Expand Up @@ -268,7 +267,7 @@ private boolean handleTestDone(JsonObject obj) throws ParseException {
//if (test.getMetadata().skip) return true; // skipped tests are reported as ignored in handleTestStart(). testFinished signal must follow

ServiceMessageBuilder testFinished = ServiceMessageBuilder.testFinished(test.getBaseName());
long duration = getTimestamp(obj) - myTestIdToTimestamp.get(test.getId());
long duration = getTimestamp(obj) - (Long)myTestIdToTimestamp.get(test.getId());
testFinished.addAttribute("duration", Long.toString(duration));

return finishMessage(testFinished, test.getId(), test.getValidParentId()) && checkGroupDone(test.getParent());
Expand Down
Loading
Loading