mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notnull ,cleanup
This commit is contained in:
+14
-11
@@ -75,13 +75,15 @@ public class IntentionManagerSettings implements PersistentStateComponent<Elemen
|
||||
registerMetaData(new IntentionActionMetaData(intentionAction, getClassLoader(intentionAction), category, descriptionDirectoryName));
|
||||
}
|
||||
|
||||
private static ClassLoader getClassLoader(final IntentionAction intentionAction) {
|
||||
private static ClassLoader getClassLoader(@NotNull IntentionAction intentionAction) {
|
||||
return intentionAction instanceof IntentionActionWrapper
|
||||
? ((IntentionActionWrapper)intentionAction).getImplementationClassLoader()
|
||||
: intentionAction.getClass().getClassLoader();
|
||||
}
|
||||
|
||||
public void registerIntentionMetaData(final IntentionAction intentionAction, final String[] category, final String descriptionDirectoryName,
|
||||
public void registerIntentionMetaData(@NotNull IntentionAction intentionAction,
|
||||
@NotNull String[] category,
|
||||
@NotNull String descriptionDirectoryName,
|
||||
final ClassLoader classLoader) {
|
||||
registerMetaData(new IntentionActionMetaData(intentionAction, classLoader, category, descriptionDirectoryName));
|
||||
}
|
||||
@@ -109,24 +111,25 @@ public class IntentionManagerSettings implements PersistentStateComponent<Elemen
|
||||
return element;
|
||||
}
|
||||
|
||||
@NotNull public synchronized List<IntentionActionMetaData> getMetaData() {
|
||||
@NotNull
|
||||
public synchronized List<IntentionActionMetaData> getMetaData() {
|
||||
IntentionManager.getInstance(); // TODO: Hack to make IntentionManager actually register metadata here. Dependencies between IntentionManager and IntentionManagerSettings should be revised.
|
||||
return new ArrayList<IntentionActionMetaData>(myMetaData.values());
|
||||
}
|
||||
|
||||
public synchronized boolean isEnabled(IntentionActionMetaData metaData) {
|
||||
public synchronized boolean isEnabled(@NotNull IntentionActionMetaData metaData) {
|
||||
return !myIgnoredActions.contains(getFamilyName(metaData));
|
||||
}
|
||||
|
||||
private static String getFamilyName(final IntentionActionMetaData metaData) {
|
||||
private static String getFamilyName(@NotNull IntentionActionMetaData metaData) {
|
||||
return StringUtil.join(metaData.myCategory, "/") + "/" + metaData.getFamily();
|
||||
}
|
||||
|
||||
private static String getFamilyName(final IntentionAction action) {
|
||||
private static String getFamilyName(@NotNull IntentionAction action) {
|
||||
return action instanceof IntentionActionWrapper ? ((IntentionActionWrapper)action).getFullFamilyName() : action.getFamilyName();
|
||||
}
|
||||
|
||||
public synchronized void setEnabled(IntentionActionMetaData metaData, boolean enabled) {
|
||||
public synchronized void setEnabled(@NotNull IntentionActionMetaData metaData, boolean enabled) {
|
||||
if (enabled) {
|
||||
myIgnoredActions.remove(getFamilyName(metaData));
|
||||
}
|
||||
@@ -135,10 +138,10 @@ public class IntentionManagerSettings implements PersistentStateComponent<Elemen
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean isEnabled(IntentionAction action) {
|
||||
public synchronized boolean isEnabled(@NotNull IntentionAction action) {
|
||||
return !myIgnoredActions.contains(getFamilyName(action));
|
||||
}
|
||||
public synchronized void setEnabled(IntentionAction action, boolean enabled) {
|
||||
public synchronized void setEnabled(@NotNull IntentionAction action, boolean enabled) {
|
||||
if (enabled) {
|
||||
myIgnoredActions.remove(getFamilyName(action));
|
||||
}
|
||||
@@ -147,7 +150,7 @@ public class IntentionManagerSettings implements PersistentStateComponent<Elemen
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void registerMetaData(IntentionActionMetaData metaData) {
|
||||
public synchronized void registerMetaData(@NotNull IntentionActionMetaData metaData) {
|
||||
MetaDataKey key = new MetaDataKey(metaData.myCategory, metaData.getFamily());
|
||||
//LOG.assertTrue(!myMetaData.containsKey(metaData.myFamily), "Action '"+metaData.myFamily+"' already registered");
|
||||
if (!myMetaData.containsKey(key)){
|
||||
@@ -182,7 +185,7 @@ public class IntentionManagerSettings implements PersistentStateComponent<Elemen
|
||||
}, 0);
|
||||
}
|
||||
|
||||
public synchronized void unregisterMetaData(IntentionAction intentionAction) {
|
||||
public synchronized void unregisterMetaData(@NotNull IntentionAction intentionAction) {
|
||||
for (Map.Entry<MetaDataKey, IntentionActionMetaData> entry : myMetaData.entrySet()) {
|
||||
if (entry.getValue().getAction() == intentionAction) {
|
||||
myMetaData.remove(entry.getKey());
|
||||
|
||||
@@ -95,27 +95,33 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
|
||||
private List<String> myModules = null;
|
||||
|
||||
public IdeaPluginDescriptorImpl(File pluginPath) {
|
||||
public IdeaPluginDescriptorImpl(@NotNull File pluginPath) {
|
||||
myPath = pluginPath;
|
||||
}
|
||||
|
||||
public void setPath(File path) {
|
||||
public void setPath(@NotNull File path) {
|
||||
myPath = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getPath() {
|
||||
return myPath;
|
||||
}
|
||||
|
||||
protected static StringInterner ourInterner = new StringInterner();
|
||||
private static final StringInterner ourInterner = new StringInterner();
|
||||
|
||||
public void readExternal(Document document, final URL url) throws InvalidDataException, FileNotFoundException {
|
||||
@NotNull
|
||||
public static String intern(@NotNull String s) {
|
||||
return ourInterner.intern(s);
|
||||
}
|
||||
|
||||
public void readExternal(@NotNull Document document, @NotNull URL url) throws InvalidDataException, FileNotFoundException {
|
||||
document = JDOMXIncluder.resolve(document, url.toExternalForm());
|
||||
JDOMUtil.internElement(document.getRootElement(), ourInterner);
|
||||
readExternal(document.getRootElement());
|
||||
}
|
||||
|
||||
public void readExternal(final URL url) throws InvalidDataException, FileNotFoundException {
|
||||
public void readExternal(@NotNull URL url) throws InvalidDataException, FileNotFoundException {
|
||||
try {
|
||||
Document document = JDOMUtil.loadDocument(url);
|
||||
readExternal(document, url);
|
||||
@@ -131,13 +137,13 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
}
|
||||
}
|
||||
|
||||
private void readExternal(Element element) {
|
||||
private void readExternal(@NotNull Element element) {
|
||||
final PluginBean pluginBean = XmlSerializer.deserialize(element, PluginBean.class);
|
||||
|
||||
url = pluginBean.url;
|
||||
myName = pluginBean.name;
|
||||
String idString = pluginBean.id;
|
||||
if (idString == null || idString.length() == 0) {
|
||||
if (idString == null || idString.isEmpty()) {
|
||||
idString = myName;
|
||||
}
|
||||
myId = PluginId.getId(idString);
|
||||
@@ -179,12 +185,12 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
if (pluginBean.dependencies != null) {
|
||||
for (PluginDependency dependency : pluginBean.dependencies) {
|
||||
String text = dependency.pluginId;
|
||||
if (text != null && text.length() > 0) {
|
||||
if (text != null && !text.isEmpty()) {
|
||||
final PluginId id = PluginId.getId(text);
|
||||
dependentPlugins.add(id);
|
||||
if (dependency.optional) {
|
||||
optionalDependentPlugins.add(id);
|
||||
if (dependency.configFile != null && dependency.configFile.length() > 0) {
|
||||
if (dependency.configFile != null && !dependency.configFile.isEmpty()) {
|
||||
myOptionalConfigs.put(id, dependency.configFile);
|
||||
}
|
||||
}
|
||||
@@ -242,58 +248,70 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
void registerExtensions() {
|
||||
if (myExtensions != null || myExtensionsPoints != null) {
|
||||
Extensions.getRootArea().getExtensionPoint(Extensions.AREA_LISTENER_EXTENSION_POINT).registerExtension(new AreaListener() {
|
||||
@Override
|
||||
public void areaCreated(String areaClass, AreaInstance areaInstance) {
|
||||
if (PluginManager.shouldSkipPlugin(IdeaPluginDescriptorImpl.this)) return;
|
||||
final ExtensionsArea area = Extensions.getArea(areaInstance);
|
||||
area.registerAreaExtensionsAndPoints(IdeaPluginDescriptorImpl.this, myExtensionsPoints, myExtensions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void areaDisposing(String areaClass, AreaInstance areaInstance) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return myDescription.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChangeNotes() {
|
||||
return myChangeNotes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PluginId[] getDependentPluginIds() {
|
||||
return myDependencies;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PluginId[] getOptionalDependentPluginIds() {
|
||||
return myOptionalDependencies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVendor() {
|
||||
return myVendor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return myVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourceBundleBaseName() {
|
||||
return myResourceBundleBaseName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategory() {
|
||||
return myCategory;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
@NotNull
|
||||
public List<File> getClassPath() {
|
||||
if (myPath.isDirectory()) {
|
||||
final List<File> result = new ArrayList<File>();
|
||||
@@ -325,34 +343,41 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public List<Element> getActionsDescriptionElements() {
|
||||
return myActionsElements;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentConfig[] getAppComponents() {
|
||||
return myAppComponents;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentConfig[] getProjectComponents() {
|
||||
return myProjectComponents;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentConfig[] getModuleComponents() {
|
||||
return myModuleComponents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVendorEmail() {
|
||||
return myVendorEmail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVendorUrl() {
|
||||
return myVendorUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
@@ -392,11 +417,13 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
return myName != null ? myName.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public HelpSetPath[] getHelpSets() {
|
||||
return myHelpSets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginId getPluginId() {
|
||||
return myId;
|
||||
}
|
||||
@@ -421,6 +448,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
myDownloadCounter = dwnlds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloads(){
|
||||
return myDownloadCounter;
|
||||
}
|
||||
@@ -455,14 +483,17 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
url = val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLoader getPluginClassLoader() {
|
||||
return myLoader != null ? myLoader : getClass().getClassLoader();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVendorLogoPath() {
|
||||
return myVendorLogoPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseIdeaClassLoader() {
|
||||
return myUseIdeaClassLoader;
|
||||
}
|
||||
@@ -504,18 +535,22 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
myDependencies = deps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return myEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(final boolean enabled) {
|
||||
myEnabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSinceBuild() {
|
||||
return mySinceBuild;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUntilBuild() {
|
||||
return myUntilBuild;
|
||||
}
|
||||
@@ -562,11 +597,11 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
private static ComponentConfig[] mergeComponents(ComponentConfig[] first, ComponentConfig[] second) {
|
||||
if (first == null) {
|
||||
return second;
|
||||
} else if (second == null) {
|
||||
return first;
|
||||
} else {
|
||||
return ArrayUtil.mergeArrays(first, second);
|
||||
}
|
||||
if (second == null) {
|
||||
return first;
|
||||
}
|
||||
return ArrayUtil.mergeArrays(first, second);
|
||||
}
|
||||
|
||||
public Boolean getSkipped() {
|
||||
@@ -577,6 +612,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
mySkipped = skipped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBundled() {
|
||||
return getPath().getAbsolutePath().startsWith(PathManager.getPreinstalledPluginsPath());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user