コード例 #1
0
  @NotNull
  public static TreeMap<String, Element> load(
      @NotNull Element rootElement,
      @Nullable PathMacroSubstitutor pathMacroSubstitutor,
      boolean intern) {
    if (pathMacroSubstitutor != null) {
      pathMacroSubstitutor.expandPaths(rootElement);
    }

    StringInterner interner = intern ? new StringInterner() : null;
    List<Element> children = rootElement.getChildren(COMPONENT);
    TreeMap<String, Element> map = new TreeMap<String, Element>();
    for (Element element : children) {
      String name = getComponentNameIfValid(element);
      if (name == null
          || !(element.getAttributes().size() > 1 || !element.getChildren().isEmpty())) {
        continue;
      }

      if (interner != null) {
        JDOMUtil.internElement(element, interner);
      }

      map.put(name, element);

      if (pathMacroSubstitutor instanceof TrackingPathMacroSubstitutor) {
        ((TrackingPathMacroSubstitutor) pathMacroSubstitutor)
            .addUnknownMacros(name, PathMacrosCollector.getMacroNames(element));
      }

      // remove only after "getMacroNames" - some PathMacroFilter requires element name attribute
      element.removeAttribute(NAME);
    }
    return map;
  }
コード例 #2
0
 public void readExternal(
     @NotNull Document document, @NotNull URL url, boolean ignoreMissingInclude)
     throws InvalidDataException, FileNotFoundException {
   document = JDOMXIncluder.resolve(document, url.toExternalForm(), ignoreMissingInclude);
   Element rootElement = document.getRootElement();
   JDOMUtil.internElement(rootElement, new StringInterner());
   readExternal(document.getRootElement());
 }
コード例 #3
0
  @Nullable
  private static List<Element> copyElements(@Nullable Element[] elements, StringInterner interner) {
    if (elements == null || elements.length == 0) {
      return null;
    }

    List<Element> result = new SmartList<Element>();
    for (Element extensionsRoot : elements) {
      for (Element element : extensionsRoot.getChildren()) {
        JDOMUtil.internElement(element, interner);
        result.add(element);
      }
    }
    return result;
  }