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);
   }
 }
  private void inspectExtension(ISchema schema, IPluginParent parent, IFile file) {
    IPluginObject[] children = parent.getChildren();

    if (parent instanceof PluginElementNode && parent.getParent() instanceof PluginElementNode) {
      // check if this node corresponds to a Java type attribute which would have been defined has
      // an element
      PluginElementNode node = (PluginElementNode) parent;
      PluginElementNode parentNode = (PluginElementNode) parent.getParent();
      ISchemaElement schemaElement = schema.findElement(parentNode.getName());
      if (schemaElement != null) {
        ISchemaAttribute attInfo = schemaElement.getAttribute(node.getName());
        if (attInfo != null && attInfo.getKind() == IMetaAttribute.JAVA)
          checkMatch(node.getAttribute("class"), file); // $NON-NLS-1$
      }
    }

    for (int i = 0; i < children.length; i++) {
      IPluginElement child = (IPluginElement) children[i];
      ISchemaElement schemaElement = schema.findElement(child.getName());
      if (schemaElement != null) {
        IPluginAttribute[] attributes = child.getAttributes();
        for (int j = 0; j < attributes.length; j++) {
          IPluginAttribute attr = attributes[j];
          ISchemaAttribute attInfo = schemaElement.getAttribute(attr.getName());
          if (attInfo != null
              && attInfo.getKind() == IMetaAttribute.JAVA
              && attr instanceof IDocumentAttributeNode) checkMatch(attr, file);
        }
      }
      inspectExtension(schema, child, file);
    }
  }
  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);
     }
   }
 }
 private void checkMatch(IPluginAttribute attr, IFile file) {
   String value = null;
   Matcher matcher = null;
   if (fSearchFor == S_FOR_TYPES) {
     value =
         removeInitializationData(attr.getValue())
             .replaceAll("\\$", "."); // $NON-NLS-1$ //$NON-NLS-2$
     matcher = getMatcher(value);
   }
   if (value == null || (matcher != null && !matcher.matches())) {
     value =
         removeInitializationData(getProperValue(attr.getValue()))
             .replaceAll("\\$", "."); // $NON-NLS-1$ //$NON-NLS-2$
     matcher = getMatcher(value);
   }
   if (matcher.matches()) {
     String group = matcher.group(0);
     int offset = ((IDocumentAttributeNode) attr).getValueOffset() + value.indexOf(group);
     int attOffset = attr.getValue().indexOf(value);
     if (attOffset != -1) offset += attOffset;
     int length = group.length();
     fSearchRequestor.reportMatch(new Match(file, Match.UNIT_CHARACTER, offset, length));
   }
 }
 /**
  * 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);
   }
 }