Пример #1
0
  public static synchronized List<EclDocCommand> getAllPublicCommands() {
    if (commands != null) return commands;

    commands = new ArrayList<EclDocCommand>();
    commandsByName = new HashMap<String, EclDocCommand>();

    for (Object o : EPackage.Registry.INSTANCE.values().toArray()) {
      try {
        if (o instanceof EPackage.Descriptor) o = ((EPackage.Descriptor) o).getEPackage();

        if (!(o instanceof EPackage)) continue;

        EPackage p = (EPackage) o;
        for (EClassifier classifier : p.getEClassifiers()) {
          if (!(classifier instanceof EClass)) continue;

          EClass class_ = (EClass) classifier;
          if (class_.isAbstract() || !class_.getEAllSuperTypes().contains(COMMAND)) continue;

          EclDocCommand command = new EclDocCommand(class_);
          if (command.isInternal() || command.isExcluded()) continue;

          if (commandsByName.containsKey(command.getName())) continue;

          commands.add(command);
          commandsByName.put(command.getName(), command);
        }
      } catch (Exception e) {
        EclDocPlugin.err("Failed to load documentation from: " + o, e);
      }
    }

    Collections.sort(
        commands,
        new Comparator<EclDocCommand>() {
          public int compare(EclDocCommand a, EclDocCommand b) {
            return a.getName().compareTo(b.getName());
          }
        });

    return commands;
  }
Пример #2
0
 protected void assertGlobalPackage(String name) {
   for (Object o : EPackage.Registry.INSTANCE.values())
     if (o instanceof EPackage) if (name.equals(((EPackage) o).getName())) return;
   fail("Package '" + name + "' has not been registered globally.");
 }