protected void collectSuites(IPluginModelBase model, Set<String> visited) { if (!model.isEnabled()) return; BundleDescription description = model.getBundleDescription(); if (!visited.add(description.getSymbolicName())) return; model.addModelChangedListener(this); listentingTo.add(model); for (IPluginExtension ext : model.getExtensions(true).getExtensions()) if ("org.xpect.testSuite".equals(ext.getPoint())) { for (IPluginObject child : ext.getChildren()) { if (child instanceof IPluginElement) { IPluginElement pluginElement = (IPluginElement) child; IPluginAttribute clazz = pluginElement.getAttribute("class"); IPluginAttribute fileExtension = pluginElement.getAttribute("fileExtension"); if (clazz != null && fileExtension != null) { LazyClass<Object> lazyClass = LazyClass.create( Object.class, clazz.getValue(), (Function<String, Class<?>>) null); TestSuiteInfo info = new TestSuiteInfo(lazyClass, Collections.singleton(fileExtension.getValue())); this.extToInfo.put(fileExtension.getValue(), info); } } } } for (BundleDescription desc : description.getDependents()) { collectSuites(PluginRegistry.findModel(desc), visited); } }
@Override protected UnitCompilerDescriptor createDescriptor(IPluginElement extPointElement) { if (extPointElement.getName().equals("unitcompiler")) { String instrName = extPointElement.getAttribute("name").getValue(); String instrClass = extPointElement.getAttribute("class").getValue(); boolean enabled = Boolean.parseBoolean(extPointElement.getAttribute("defaultEnabled").getValue()); IReportableUnitCompiler.Level defaultLevel = IReportableUnitCompiler.Level.IGNORE; try { String level = extPointElement.getAttribute("report").getValue(); defaultLevel = IReportableUnitCompiler.Level.valueOf(level.toUpperCase()); } catch (Exception e) { // noop } StringBuilder instrDesc = new StringBuilder(); for (IPluginObject child : extPointElement.getChildren()) { IPluginElement childElement = (IPluginElement) child; if (childElement.getName().equals("description")) instrDesc.append(childElement.getText()).append(" "); } if (LOGGER.isDebugEnabled()) LOGGER.debug( "Adding extension of unitcompiler from " + extPointElement.getPluginBase().getId() + " named:" + instrName + " class:" + instrClass + " desc:" + instrDesc); return new UnitCompilerDescriptor( extPointElement.getPluginBase().getId(), instrName, instrClass, instrDesc.toString(), enabled, defaultLevel); } else throw new IllegalArgumentException( "Was expecting unitcompiler tag, got " + extPointElement.getName()); }
/** * Process category elements * * @param parentElement */ private void updateUICategoryComboElement(IPluginElement parentElement) { // Get the id attribute IPluginAttribute idAttribute = parentElement.getAttribute(ICompCSConstants.ATTRIBUTE_ID); // Get the name attribute IPluginAttribute nameAttribute = parentElement.getAttribute(ICompCSConstants.ATTRIBUTE_NAME); // Add the category to the combo box only if // (1) the category name is defined // (2) the category has not already been added to the combo box if ((nameAttribute != null) && PDETextHelper.isDefined(nameAttribute.getValue()) && (idAttribute != null) && PDETextHelper.isDefined(idAttribute.getValue()) && (fCategoryTrackerUtil.containsCategoryName(nameAttribute.getValue()) == false)) { // TODO: MP: LOW: CompCS: Reference translated value fCategoryCombo.add(nameAttribute.getValue()); // Assocate the category ID with the category name fCategoryTrackerUtil.associate( idAttribute.getValue(), nameAttribute.getValue(), CSCategoryTrackerUtil.F_TYPE_OLD_CATEGORY); } }
private void processCheatSheetElement(IPluginElement parentElement, String generatedID) { // Get the id attribute IPluginAttribute idAttribute = parentElement.getAttribute(ICompCSConstants.ATTRIBUTE_ID); // Check for the generated ID for this cheat sheet // If a cheat sheet exists with the generated ID already, read its // description and populate the description text accordingly if ((idAttribute != null) && PDETextHelper.isDefined(idAttribute.getValue()) && generatedID.equals(idAttribute.getValue())) { // Matching cheat sheet extension found // Process children if any if (parentElement.getChildCount() > 0) { // Update the description text widget updateUIDescriptionText(parentElement); } updateUICategoryComboAttribute(parentElement); } }
/** * Process cheatsheet elements with a category attribute * * @param parentElement */ private void updateUICategoryComboAttribute(IPluginElement element) { // Get the category attribute IPluginAttribute categoryAttribute = element.getAttribute(F_CS_ELEMENT_CATEGORY); // Process the category attribute if ((categoryAttribute != null) && PDETextHelper.isDefined(categoryAttribute.getValue())) { String id = categoryAttribute.getValue(); // Check to see if the category ID has been defined if (fCategoryTrackerUtil.containsCategoryID(id)) { // Update the category combo selection String name = fCategoryTrackerUtil.getCategoryName(id); fCategoryCombo.setText(name); } else { // Add the category ID to the combo box (no assoicated name) // This can only happen if the category is defined outside of // the plug-in the cheat sheet is stored in fCategoryCombo.add(id); fCategoryCombo.setText(id); fCategoryTrackerUtil.associate(id, id, CSCategoryTrackerUtil.F_TYPE_OLD_CATEGORY); } } }