}
/**
- * Return class of specific class id which extends specific extension point id.
+ * Return class of specific class id which extends specific extension point id.
* @param extPointId - extension point id.
* @param classId - class id.
* @return object class of specific class id which extends specific extension point id.
}
return null;
}
+
+ /**
+ * Return object of specific attribute which extends specific extension point id.
+ * @param extPointId - extension point id.
+ * @param attribute - attribute.
+ * @return object of specific attribute which extends specific extension point id.
+ */
+ public static Object[] getExtensionAttribute(String extPointId, String attribute) throws CoreException {
+ IExtensionRegistry registry = platformSurrogate.getAdapter();
+ IExtensionPoint ep = registry.getExtensionPoint(extPointId );
+ IExtension[] exts = ep.getExtensions();
+ List<String> values = new ArrayList<String>();
+
+ for ( IExtension ext : exts ) {
+ IConfigurationElement[] configs = ext.getConfigurationElements();
+ for ( final IConfigurationElement config : configs ) {
+ String value = config.getAttribute(attribute);
+ if (value != null && !value.isEmpty()) {
+ values.add(value);
+ }
+ }
+ }
+
+ return values.toArray();
+ }
+
}
Mockito.verify(config).createExecutableExtension("class");
}
+ /**
+ * Test {@link PluginUtil#getExtensionAttribute(String, String)}
+ *
+ * @throws Exception in case of failure in test
+ *
+ * @see PluginUtil#getExtensionAttribute(String, String)
+ */
+ @Test
+ public void testGetExtensionAttribute() throws Exception {
+ when(config.getAttribute("extension")).thenReturn("css");
+ PluginUtil.getExtensionAttribute(TEST_EXT_ID, "extension");
+ Mockito.verify(config).getAttribute("extension");
+ }
}