mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 06:39:38 +07:00
cleanup
This commit is contained in:
@@ -184,10 +184,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
catch (FileNotFoundException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new InvalidDataException(e);
|
||||
}
|
||||
catch (JDOMException e) {
|
||||
catch (IOException | JDOMException e) {
|
||||
throw new InvalidDataException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,11 @@ package com.intellij.ide.plugins;
|
||||
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -27,13 +30,13 @@ class PluginClassCache {
|
||||
private static final Object ourLock = new Object();
|
||||
private final TObjectIntHashMap<PluginId> myClassCounts = new TObjectIntHashMap<>();
|
||||
|
||||
public void addPluginClass(PluginId pluginId) {
|
||||
void addPluginClass(@NotNull PluginId pluginId) {
|
||||
synchronized(ourLock) {
|
||||
myClassCounts.put(pluginId, myClassCounts.get(pluginId) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void dumpPluginClassStatistics() {
|
||||
void dumpPluginClassStatistics() {
|
||||
if (!Boolean.valueOf(System.getProperty("idea.is.internal")).booleanValue()) return;
|
||||
|
||||
List<PluginId> counters;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class PluginManagerCore {
|
||||
public static final float LOADERS_PROGRESS_PART = 0.35f;
|
||||
|
||||
private static final TObjectIntHashMap<PluginId> ourId2Index = new TObjectIntHashMap<>();
|
||||
static final String MODULE_DEPENDENCY_PREFIX = "com.intellij.module";
|
||||
private static final String MODULE_DEPENDENCY_PREFIX = "com.intellij.module";
|
||||
private static final Map<String, IdeaPluginDescriptorImpl> ourModulesToContainingPlugins = new THashMap<>();
|
||||
private static final PluginClassCache ourPluginClasses = new PluginClassCache();
|
||||
private static final String SPECIAL_IDEA_PLUGIN = "IDEA CORE";
|
||||
@@ -131,8 +131,7 @@ public class PluginManagerCore {
|
||||
List<String> requiredPlugins = StringUtil.split(System.getProperty("idea.required.plugins.id", ""), ",");
|
||||
if (file.isFile()) {
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
try {
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
String id;
|
||||
while ((id = reader.readLine()) != null) {
|
||||
id = id.trim();
|
||||
@@ -142,7 +141,6 @@ public class PluginManagerCore {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
reader.close();
|
||||
if (!requiredPlugins.isEmpty()) {
|
||||
savePluginsList(disabledPlugins, false, new File(PathManager.getConfigPath(), DISABLED_PLUGINS_FILENAME));
|
||||
fireEditDisablePlugins();
|
||||
@@ -446,13 +444,7 @@ public class PluginManagerCore {
|
||||
|
||||
return loader;
|
||||
}
|
||||
catch (IOException e) {
|
||||
getLogger().warn(e);
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
getLogger().warn(e);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
catch (IOException | IllegalAccessException | InvocationTargetException e) {
|
||||
getLogger().warn(e);
|
||||
}
|
||||
}
|
||||
@@ -470,9 +462,6 @@ public class PluginManagerCore {
|
||||
}
|
||||
return new PluginClassLoader(urls, parentLoaders, pluginId, pluginDescriptor.getVersion(), pluginRoot);
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
getLogger().warn(e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
getLogger().warn(e);
|
||||
}
|
||||
@@ -668,8 +657,7 @@ public class PluginManagerCore {
|
||||
try {
|
||||
URL jarURL = URLUtil.getJarEntryURL(file, META_INF + '/' + fileName);
|
||||
|
||||
ZipFile zipFile = new ZipFile(file);
|
||||
try {
|
||||
try (ZipFile zipFile = new ZipFile(file)) {
|
||||
ZipEntry entry = zipFile.getEntry(META_INF + '/' + fileName);
|
||||
if (entry != null) {
|
||||
Document document = JDOMUtil.loadDocument(zipFile.getInputStream(entry));
|
||||
@@ -678,9 +666,6 @@ public class PluginManagerCore {
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
zipFile.close();
|
||||
}
|
||||
}
|
||||
catch (XmlSerializationException e) {
|
||||
getLogger().info("Cannot load " + file, e);
|
||||
@@ -842,7 +827,7 @@ public class PluginManagerCore {
|
||||
final LinkedHashSet<String> faultyDescriptors = new LinkedHashSet<>();
|
||||
for (final Iterator<? extends IdeaPluginDescriptor> it = result.iterator(); it.hasNext();) {
|
||||
final IdeaPluginDescriptor pluginDescriptor = it.next();
|
||||
checkDependants(pluginDescriptor, pluginId -> idToDescriptorMap.get(pluginId), pluginId -> {
|
||||
checkDependants(pluginDescriptor, idToDescriptorMap::get, pluginId -> {
|
||||
if (!idToDescriptorMap.containsKey(pluginId)) {
|
||||
pluginDescriptor.setEnabled(false);
|
||||
if (!pluginId.getIdString().startsWith(MODULE_DEPENDENCY_PREFIX)) {
|
||||
@@ -1055,7 +1040,6 @@ public class PluginManagerCore {
|
||||
/**
|
||||
* Checks if plugin should be loaded and return the reason why it should not
|
||||
* @param descriptor plugin to check
|
||||
* @param loaded
|
||||
* @return null if plugin should be loaded, string with the reason why plugin should not be loaded
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.ide.plugins;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.ThreeState;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -35,8 +34,8 @@ import java.util.List;
|
||||
class PluginXmlPathResolver implements JDOMXIncluder.PathResolver {
|
||||
private final List<File> myPluginJarFiles;
|
||||
|
||||
public PluginXmlPathResolver(File[] filesInLib) {
|
||||
myPluginJarFiles = ContainerUtil.filter(filesInLib, file -> FileUtil.isJarOrZip(file));
|
||||
PluginXmlPathResolver(@NotNull File[] filesInLib) {
|
||||
myPluginJarFiles = ContainerUtil.filter(filesInLib, FileUtil::isJarOrZip);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -248,9 +248,9 @@ public final class LoadTextUtil {
|
||||
|
||||
@NotNull
|
||||
private static Pair.NonNull<Charset, byte[]> charsetForWriting(@Nullable Project project,
|
||||
@NotNull VirtualFile virtualFile,
|
||||
@NotNull String text,
|
||||
@NotNull Charset existing) {
|
||||
@NotNull VirtualFile virtualFile,
|
||||
@NotNull String text,
|
||||
@NotNull Charset existing) {
|
||||
Charset specified = extractCharsetFromFileContent(project, virtualFile, text);
|
||||
Pair.NonNull<Charset, byte[]> chosen = chooseMostlyHarmlessCharset(existing, specified, text);
|
||||
Charset charset = chosen.first;
|
||||
|
||||
@@ -43,12 +43,7 @@ public class PluginId implements Comparable<PluginId> {
|
||||
|
||||
@NotNull
|
||||
public static synchronized PluginId getId(@NotNull String idString) {
|
||||
PluginId pluginId = ourRegisteredIds.get(idString);
|
||||
if (pluginId == null) {
|
||||
pluginId = new PluginId(idString);
|
||||
ourRegisteredIds.put(idString, pluginId);
|
||||
}
|
||||
return pluginId;
|
||||
return ourRegisteredIds.computeIfAbsent(idString, PluginId::new);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user