mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -29,8 +29,8 @@ public class BuildNumber implements Comparable<BuildNumber> {
|
||||
|
||||
public static final int SNAPSHOT_VALUE = Integer.MAX_VALUE;
|
||||
|
||||
private final @NotNull String myProductCode;
|
||||
private final @NotNull int[] myComponents;
|
||||
@NotNull private final String myProductCode;
|
||||
@NotNull private final int[] myComponents;
|
||||
|
||||
public BuildNumber(@NotNull String productCode, int baselineVersion, int buildNumber) {
|
||||
this(productCode, new int[]{baselineVersion, buildNumber});
|
||||
@@ -41,7 +41,8 @@ public class BuildNumber implements Comparable<BuildNumber> {
|
||||
myComponents = components;
|
||||
}
|
||||
|
||||
public @NotNull String getProductCode() {
|
||||
@NotNull
|
||||
public String getProductCode() {
|
||||
return myProductCode;
|
||||
}
|
||||
|
||||
@@ -49,7 +50,8 @@ public class BuildNumber implements Comparable<BuildNumber> {
|
||||
return myComponents[0];
|
||||
}
|
||||
|
||||
public @NotNull int[] getComponents() {
|
||||
@NotNull
|
||||
public int[] getComponents() {
|
||||
return myComponents.clone();
|
||||
}
|
||||
|
||||
@@ -57,23 +59,28 @@ public class BuildNumber implements Comparable<BuildNumber> {
|
||||
return ArrayUtil.indexOf(myComponents, SNAPSHOT_VALUE) >= 0;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Contract(pure = true)
|
||||
public @NotNull BuildNumber withoutProductCode() {
|
||||
public BuildNumber withoutProductCode() {
|
||||
return myProductCode.isEmpty() ? this : new BuildNumber("", myComponents);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String asString() {
|
||||
return asString(true, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String asStringWithoutProductCode() {
|
||||
return asString(false, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String asStringWithoutProductCodeAndSnapshot() {
|
||||
return asString(false, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String asString(boolean includeProductCode, boolean withSnapshotMarker) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
@@ -99,7 +106,7 @@ public class BuildNumber implements Comparable<BuildNumber> {
|
||||
return fromString(version, null, null);
|
||||
}
|
||||
|
||||
public static BuildNumber fromStringWithProductCode(String version, String productCode) {
|
||||
public static BuildNumber fromStringWithProductCode(String version, @NotNull String productCode) {
|
||||
return fromString(version, null, productCode);
|
||||
}
|
||||
|
||||
@@ -122,8 +129,6 @@ public class BuildNumber implements Comparable<BuildNumber> {
|
||||
}
|
||||
|
||||
int baselineVersionSeparator = code.indexOf('.');
|
||||
int baselineVersion;
|
||||
int buildNumber;
|
||||
|
||||
if (baselineVersionSeparator > 0) {
|
||||
String baselineVersionString = code.substring(0, baselineVersionSeparator);
|
||||
@@ -142,18 +147,18 @@ public class BuildNumber implements Comparable<BuildNumber> {
|
||||
return new BuildNumber(productCode, intComponents);
|
||||
}
|
||||
else {
|
||||
buildNumber = parseBuildNumber(version, code, pluginName);
|
||||
int buildNumber = parseBuildNumber(version, code, pluginName);
|
||||
if (buildNumber <= 2000) {
|
||||
// it's probably a baseline, not a build number
|
||||
return new BuildNumber(productCode, buildNumber, 0);
|
||||
}
|
||||
|
||||
baselineVersion = getBaseLineForHistoricBuilds(buildNumber);
|
||||
int baselineVersion = getBaseLineForHistoricBuilds(buildNumber);
|
||||
return new BuildNumber(productCode, baselineVersion, buildNumber);
|
||||
}
|
||||
}
|
||||
|
||||
private static int parseBuildNumber(String version, String code, String pluginName) {
|
||||
private static int parseBuildNumber(String version, @NotNull String code, String pluginName) {
|
||||
if (SNAPSHOT.equals(code) || BUILD_NUMBER_PLACEHOLDERS.contains(code) || STAR.equals(code)) {
|
||||
return SNAPSHOT_VALUE;
|
||||
}
|
||||
@@ -190,9 +195,7 @@ public class BuildNumber implements Comparable<BuildNumber> {
|
||||
BuildNumber that = (BuildNumber)o;
|
||||
|
||||
if (!myProductCode.equals(that.myProductCode)) return false;
|
||||
if (!Arrays.equals(myComponents, that.myComponents)) return false;
|
||||
|
||||
return true;
|
||||
return Arrays.equals(myComponents, that.myComponents);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.ide.StartupProgress;
|
||||
import com.intellij.ide.plugins.cl.PluginClassLoader;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.JetBrainsProtocolHandler;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
@@ -51,7 +52,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import static com.intellij.openapi.application.JetBrainsProtocolHandler.REQUIRED_PLUGINS_KEY;
|
||||
import static com.intellij.util.ObjectUtils.notNull;
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class PluginManagerCore {
|
||||
private static List<String> ourDisabledPlugins;
|
||||
private static MultiMap<String, String> ourBrokenPluginVersions;
|
||||
private static IdeaPluginDescriptor[] ourPlugins;
|
||||
private static boolean ourUnitTestWithBundledPlugins = false;
|
||||
private static boolean ourUnitTestWithBundledPlugins;
|
||||
|
||||
static String myPluginError;
|
||||
static List<String> myPlugins2Disable;
|
||||
@@ -137,7 +137,7 @@ public class PluginManagerCore {
|
||||
File file = new File(configPath, DISABLED_PLUGINS_FILENAME);
|
||||
if (file.isFile()) {
|
||||
ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
|
||||
List<String> requiredPlugins = StringUtil.split(System.getProperty(REQUIRED_PLUGINS_KEY, ""), ",");
|
||||
List<String> requiredPlugins = StringUtil.split(System.getProperty(JetBrainsProtocolHandler.REQUIRED_PLUGINS_KEY, ""), ",");
|
||||
try {
|
||||
boolean updateDisablePluginsList = false;
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
@@ -429,8 +429,7 @@ public class PluginManagerCore {
|
||||
return loadPlugins == null || Boolean.TRUE.toString().equals(loadPlugins);
|
||||
}
|
||||
|
||||
// used in upsource
|
||||
public static void configureExtensions() {
|
||||
private static void configureExtensions() {
|
||||
Extensions.registerAreaClass(ExtensionAreas.IDEA_PROJECT, null);
|
||||
Extensions.registerAreaClass(ExtensionAreas.IDEA_MODULE, ExtensionAreas.IDEA_PROJECT);
|
||||
}
|
||||
@@ -879,9 +878,9 @@ public class PluginManagerCore {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void resolveOptionalDescriptors(@NotNull String fileName,
|
||||
@NotNull IdeaPluginDescriptorImpl descriptor,
|
||||
@NotNull Function<? super String, ? extends IdeaPluginDescriptorImpl> optionalDescriptorLoader) {
|
||||
private static void resolveOptionalDescriptors(@NotNull String fileName,
|
||||
@NotNull IdeaPluginDescriptorImpl descriptor,
|
||||
@NotNull Function<? super String, ? extends IdeaPluginDescriptorImpl> optionalDescriptorLoader) {
|
||||
Map<PluginId, List<String>> optionalConfigs = descriptor.getOptionalConfigs();
|
||||
if (optionalConfigs != null && !optionalConfigs.isEmpty()) {
|
||||
Map<PluginId, List<IdeaPluginDescriptorImpl>> descriptors = new THashMap<>(optionalConfigs.size());
|
||||
@@ -1067,7 +1066,7 @@ public class PluginManagerCore {
|
||||
descriptor.setUseCoreClassLoader(true);
|
||||
result.add(descriptor);
|
||||
if (progress != null && !SPECIAL_IDEA_PLUGIN.equals(descriptor.getName())) {
|
||||
progress.showProgress("Plugin loaded: " + descriptor.getName(), PLUGINS_PROGRESS_PART * (float)(++i) / urls.size());
|
||||
progress.showProgress("Plugin loaded: " + descriptor.getName(), PLUGINS_PROGRESS_PART * (++i) / urls.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1153,8 +1152,8 @@ public class PluginManagerCore {
|
||||
return topoSortPlugins(result, errors);
|
||||
}
|
||||
|
||||
@NotNull // used in upsource
|
||||
public static IdeaPluginDescriptorImpl[] topoSortPlugins(@NotNull List<IdeaPluginDescriptorImpl> result, @NotNull List<? super String> errors) {
|
||||
@NotNull
|
||||
private static IdeaPluginDescriptorImpl[] topoSortPlugins(@NotNull List<IdeaPluginDescriptorImpl> result, @NotNull List<? super String> errors) {
|
||||
IdeaPluginDescriptorImpl[] pluginDescriptors = result.toArray(IdeaPluginDescriptorImpl.EMPTY_ARRAY);
|
||||
|
||||
Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap = new THashMap<>();
|
||||
@@ -1372,7 +1371,7 @@ public class PluginManagerCore {
|
||||
}
|
||||
|
||||
if (progress != null) {
|
||||
progress.showProgress("", PLUGINS_PROGRESS_PART + (i++ / (float)result.size()) * LOADERS_PROGRESS_PART);
|
||||
progress.showProgress("", PLUGINS_PROGRESS_PART + i++ / (float)result.size() * LOADERS_PROGRESS_PART);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1390,14 +1389,13 @@ public class PluginManagerCore {
|
||||
ourPlugins = pluginDescriptors;
|
||||
}
|
||||
|
||||
// used in upsource
|
||||
public static void fixDescriptors(@NotNull IdeaPluginDescriptorImpl[] pluginDescriptors,
|
||||
@NotNull ClassLoader parentLoader,
|
||||
@NotNull Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap,
|
||||
@NotNull Map<String, String> disabledPluginNames,
|
||||
@NotNull List<? super String> brokenPluginsList,
|
||||
@NotNull List<IdeaPluginDescriptorImpl> result,
|
||||
@NotNull List<? super String> errors) {
|
||||
private static void fixDescriptors(@NotNull IdeaPluginDescriptorImpl[] pluginDescriptors,
|
||||
@NotNull ClassLoader parentLoader,
|
||||
@NotNull Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap,
|
||||
@NotNull Map<String, String> disabledPluginNames,
|
||||
@NotNull List<? super String> brokenPluginsList,
|
||||
@NotNull List<IdeaPluginDescriptorImpl> result,
|
||||
@NotNull List<? super String> errors) {
|
||||
checkCanLoadPlugins(pluginDescriptors, parentLoader, disabledPluginNames, brokenPluginsList, result);
|
||||
|
||||
filterBadPlugins(result, disabledPluginNames, errors);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class JobLauncherImpl extends JobLauncher {
|
||||
// call checkCanceled a bit more often than .invoke()
|
||||
while (!applier.isDone()) {
|
||||
ProgressManager.checkCanceled();
|
||||
// does automatic compensation against starvation
|
||||
// does automatic compensation against starvation (in ForkJoinPool.awaitJoin)
|
||||
try {
|
||||
applier.get(1, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class PluginInstaller {
|
||||
installedDependant.add(pluginNode);
|
||||
|
||||
// check for dependent plugins at first.
|
||||
if (pluginNode.getDepends() != null && pluginNode.getDepends().size() > 0) {
|
||||
if (pluginNode.getDepends() != null && !pluginNode.getDepends().isEmpty()) {
|
||||
// prepare plugins list for install
|
||||
final PluginId[] optionalDependentPluginIds = pluginNode.getOptionalDependentPluginIds();
|
||||
final List<PluginNode> depends = new ArrayList<>();
|
||||
@@ -141,7 +141,7 @@ public class PluginInstaller {
|
||||
PluginId depPluginId = pluginNode.getDepends().get(i);
|
||||
if (PluginManager.isPluginInstalled(depPluginId) || PluginManagerCore.isModuleDependency(depPluginId) ||
|
||||
InstalledPluginsState.getInstance().wasInstalled(depPluginId) ||
|
||||
(pluginIds != null && pluginIds.contains(depPluginId))) {
|
||||
pluginIds != null && pluginIds.contains(depPluginId)) {
|
||||
// ignore installed or installing plugins
|
||||
continue;
|
||||
}
|
||||
@@ -150,7 +150,8 @@ public class PluginInstaller {
|
||||
PluginNode depPlugin;
|
||||
if (depPluginDescriptor instanceof PluginNode) {
|
||||
depPlugin = (PluginNode) depPluginDescriptor;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
depPlugin = new PluginNode(depPluginId, depPluginId.getIdString(), "-1");
|
||||
}
|
||||
|
||||
@@ -164,7 +165,7 @@ public class PluginInstaller {
|
||||
}
|
||||
}
|
||||
|
||||
if (depends.size() > 0) { // has something to install prior installing the plugin
|
||||
if (!depends.isEmpty()) { // has something to install prior installing the plugin
|
||||
final boolean[] proceed = new boolean[1];
|
||||
try {
|
||||
ApplicationManager.getApplication().invokeAndWait(() -> {
|
||||
@@ -182,7 +183,7 @@ public class PluginInstaller {
|
||||
}
|
||||
}
|
||||
|
||||
if (optionalDeps.size() > 0) {
|
||||
if (!optionalDeps.isEmpty()) {
|
||||
final boolean[] proceed = new boolean[1];
|
||||
try {
|
||||
ApplicationManager.getApplication().invokeAndWait(() -> {
|
||||
|
||||
@@ -56,17 +56,17 @@ public class PluginNode implements IdeaPluginDescriptor {
|
||||
|
||||
public PluginNode() { }
|
||||
|
||||
public PluginNode(PluginId id) {
|
||||
public PluginNode(@NotNull PluginId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public PluginNode(PluginId id, String name, String size) {
|
||||
public PluginNode(@NotNull PluginId id, String name, String size) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
public void setCategory(@NotNull String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
@@ -75,14 +75,14 @@ public class PluginNode implements IdeaPluginDescriptor {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public void setName(@NotNull String name) {
|
||||
if (id == null) {
|
||||
id = PluginId.getId(name);
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
public void setId(@NotNull String id) {
|
||||
this.id = PluginId.getId(id);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class PluginNode implements IdeaPluginDescriptor {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
public void setVendor(String vendor) {
|
||||
public void setVendor(@NotNull String vendor) {
|
||||
this.vendor = vendor;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class PluginNode implements IdeaPluginDescriptor {
|
||||
return changeNotes;
|
||||
}
|
||||
|
||||
public void setChangeNotes(String changeNotes) {
|
||||
public void setChangeNotes(@NotNull String changeNotes) {
|
||||
this.changeNotes = changeNotes;
|
||||
}
|
||||
|
||||
@@ -263,12 +263,12 @@ public class PluginNode implements IdeaPluginDescriptor {
|
||||
return myDependencies;
|
||||
}
|
||||
|
||||
public void setDepends(List<PluginId> depends, @Nullable PluginId[] optionalDependencies) {
|
||||
public void setDepends(@NotNull List<? extends PluginId> depends, @Nullable PluginId[] optionalDependencies) {
|
||||
myDependencies = new ArrayList<>(depends);
|
||||
myOptionalDependencies = optionalDependencies;
|
||||
}
|
||||
|
||||
public void addDepends(String id) {
|
||||
public void addDepends(@NotNull String id) {
|
||||
(myDependencies != null ? myDependencies : (myDependencies = new ArrayList<>())).add(PluginId.getId(id));
|
||||
}
|
||||
|
||||
@@ -276,11 +276,11 @@ public class PluginNode implements IdeaPluginDescriptor {
|
||||
return myTags;
|
||||
}
|
||||
|
||||
public void setTags(List<String> tags) {
|
||||
public void setTags(@NotNull List<String> tags) {
|
||||
myTags = new ArrayList<>(tags);
|
||||
}
|
||||
|
||||
void addTags(String tag) {
|
||||
void addTags(@NotNull String tag) {
|
||||
(myTags != null ? myTags : (myTags = new ArrayList<>())).add(tag);
|
||||
}
|
||||
|
||||
|
||||
@@ -151,6 +151,7 @@ class RepositoryContentHandler extends DefaultHandler {
|
||||
currentValue.append(ch, start, length);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String buildCategoryName() {
|
||||
if (categoryName == null) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user