コード例 #1
0
  private Trie<Object> createTrie() throws ModelOperationException {
    Trie<Object> trie = new Trie<Object>();

    for (AssetContainer assetContainer : app.getAllAssetContainers()) {
      try {
        if (assetContainer instanceof BundlableNode) {
          BundlableNode bundlableNode = (BundlableNode) assetContainer;

          for (AliasDefinition aliasDefinition : bundlableNode.aliasesFile().aliasDefinitions()) {
            if (!trie.containsKey(aliasDefinition.getName())) {
              trie.add(aliasDefinition.getName(), new AliasName(aliasDefinition.getName()));
            }
          }
        }

        for (SourceFile sourceFile : assetContainer.sourceFiles()) {
          ClassSourceFile classSourceFile = new ClassSourceFile(sourceFile);

          if (!sourceFile.getUnderlyingFile().equals(assetFile)) {
            trie.add(sourceFile.getRequirePath(), sourceFile);
            trie.add(classSourceFile.getClassName(), classSourceFile);
          }
        }

        for (AssetLocation assetLocation : assetContainer.getAllAssetLocations()) {
          for (AliasDefinition aliasDefinition :
              assetLocation.aliasDefinitionsFile().aliasDefinitions()) {
            if (!trie.containsKey(aliasDefinition.getName())) {
              trie.add(aliasDefinition.getName(), new AliasName(aliasDefinition.getName()));
            }
          }
        }
      } catch (TrieKeyAlreadyExistsException
          | EmptyTrieKeyException
          | BundlerFileProcessingException ex) {
        throw new ModelOperationException(ex);
      }
    }

    return trie;
  }