Parse a list of blocks and replace suite of Blocks matching the icon mapping definitions by image blocks.

@param sourceBlocks the blocks to parse
511269
private void parseTree(List<Block> sourceBlocks)
    {
        Block matchStartBlock = null;
        int count = 0;
        Block mappingCursor = this.mappingTree.getChildren().get(0);
        Block sourceBlock = sourceBlocks.get(0);
        while (sourceBlock != null) {
            while (mappingCursor != null) {
                if (blockEquals(sourceBlock, mappingCursor)) {
                    if (matchStartBlock == null) {
                        matchStartBlock = sourceBlock;
                    }
                    count++;
                    mappingCursor = mappingCursor.getChildren().get(0);
                    // If we reach the Image Block then we've found a match!
                    if (mappingCursor instanceof ImageBlock) {
                        // Replace the first source block with the image block and remove all other blocks...
                        for (int i = 0; i < count - 1; i++) {
                            matchStartBlock.getParent().removeBlock(matchStartBlock.getNextSibling());
                        }
                        sourceBlock = mappingCursor.clone();
                        matchStartBlock.getParent().replaceChild(sourceBlock, matchStartBlock);
                        mappingCursor = null;
                        matchStartBlock = null;
                        count = 0;
                    } else {
                        // Look for next block match
                        break;
                    }
                } else {
                    mappingCursor = mappingCursor.getNextSibling();
                }
            }
            // Look for a match in children of the source block
            List<Block> filteredSourceBlocks = this.filter.filter(sourceBlock.getChildren());
            if (!filteredSourceBlocks.isEmpty()) {
                parseTree(filteredSourceBlocks);
            } else if (mappingCursor == null) {
                // No match has been found, reset state variables
                mappingCursor = this.mappingTree.getChildren().get(0);
                count = 0;
                matchStartBlock = null;
            }
            sourceBlock = this.filter.getNextSibling(sourceBlock);
        }
    }
1105022
function(block) {
  switch(block.t) {
    case 'Paragraph':
    case 'SetextHeader':
    case 'ATXHeader':
      block.inline_content =
        this.inlineParser.parse(block.string_content.trim(), this.refmap);
      block.string_content = "";
      break;
    default:
      break;
  }

  if (block.children) {
    for (var i = 0; i < block.children.length; i++) {
      this.processInlines(block.children[i]);
    }
  }

}
663902
@Override
    public boolean parseParameters(Object params)
    {
        if (params == null || !(params instanceof BuildBattleDecorator))
            return false;

        this.params = (BuildBattleDecorator) params;

        this.sourceBounds = this.params.getGoalStructureBounds();
        this.destBounds = this.params.getPlayerStructureBounds();
        this.delta = new Vec3i(destBounds.getMin().getX() - sourceBounds.getMin().getX(),
                               destBounds.getMin().getY() - sourceBounds.getMin().getY(),
                               destBounds.getMin().getZ() - sourceBounds.getMin().getZ());
        
        this.structureVolume = volumeOfBounds(this.sourceBounds);
        assert(this.structureVolume == volumeOfBounds(this.destBounds));
        this.dest = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState)null));
        this.source = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState)null));
        
        DrawBlockBasedObjectType tickBlock = this.params.getBlockTypeOnCorrectPlacement();
        DrawBlockBasedObjectType crossBlock = this.params.getBlockTypeOnIncorrectPlacement();

        this.blockTypeOnCorrectPlacement = (tickBlock != null) ? new XMLBlockState(tickBlock.getType(), tickBlock.getColour(), tickBlock.getFace(), tickBlock.getVariant()) : null;
        this.blockTypeOnIncorrectPlacement = (crossBlock != null) ? new XMLBlockState(crossBlock.getType(), crossBlock.getColour(), crossBlock.getFace(), crossBlock.getVariant()) : null;
        return true;
    }
451573
protected function compileNestedBlock(Block $block, $selectors)
    {
        $this->pushEnv($block);

        $this->scope = $this->makeOutputBlock($block->type, $selectors);
        $this->scope->parent->children[] = $this->scope;

        // wrap assign children in a block
        foreach ($block->children as $k => $child) {
            if ($child[0] === Type::T_ASSIGN) {
                $wrapped = new Block;
                $wrapped->sourceName   = $block->sourceName;
                $wrapped->sourceIndex  = $block->sourceIndex;
                $wrapped->sourceLine   = $block->sourceLine;
                $wrapped->sourceColumn = $block->sourceColumn;
                $wrapped->selectors    = [];
                $wrapped->comments     = [];
                $wrapped->parent       = $block;
                $wrapped->children     = [$child];
                $wrapped->selfParent   = $block->selfParent;

                $block->children[$k] = [Type::T_BLOCK, $wrapped];
            }
        }

        $this->compileChildrenNoReturn($block->children, $this->scope);

        $this->scope = $this->scope->parent;

        $this->popEnv();
    }
584619
private List<JqassistantRules> readXmlSource(RuleSource ruleSource) {
        List<JqassistantRules> rules = new ArrayList<>();
        try (InputStream inputStream = ruleSource.getInputStream()) {
            JqassistantRules jqassistantRules = jaxbUnmarshaller.unmarshal(inputStream);
            rules.add(jqassistantRules);
        } catch (IOException e) {
            throw new IllegalArgumentException("Cannot read rules from '" + ruleSource.getId() + "'.", e);
        }
        return rules;
    }
1101444
private void updateBlocks() {
        for (Block<S, L> block : splitBlocks) {
            // Ignore blocks that have no elements in their sub blocks.
            int inSubBlocks = block.getElementsInSubBlocks();
            if (inSubBlocks == 0) {
                continue;
            }

            boolean blockRemains = (inSubBlocks < block.size());

            boolean reuseBlock = !blockRemains;

            List<UnorderedCollection<State<S, L>>> subBlocks = block.getSubBlocks();
            // If there is only one sub block which contains all elements of
            // the block, then no split needs to be performed.
            if (!blockRemains && subBlocks.size() == 1) {
                block.clearSubBlocks();
                continue;
            }

            Iterator<UnorderedCollection<State<S, L>>> subBlockIt = subBlocks.iterator();

            if (reuseBlock) {
                UnorderedCollection<State<S, L>> first = subBlockIt.next();
                block.getStates().swap(first);
                updateBlockReferences(block);
            }

            while (subBlockIt.hasNext()) {
                UnorderedCollection<State<S, L>> subBlockStates = subBlockIt.next();

                if (blockRemains) {
                    for (State<S, L> state : subBlockStates) {
                        block.removeState(state.getBlockReference());
                    }
                }

                Block<S, L> subBlock = new Block<>(numBlocks++, subBlockStates);
                updateBlockReferences(subBlock);
                newBlocks.add(subBlock);
                addToPartition(subBlock);
            }

            newBlocks.add(block);
            block.clearSubBlocks();

            // If the split block previously was in the queue, add all newly
            // created blocks to the queue. Otherwise, it's enough to add
            // all but the largest
            if (removeFromSplitterQueue(block)) {
                addAllToSplitterQueue(newBlocks);
            } else {
                addAllButLargest(newBlocks);
            }
            newBlocks.clear();
        }

        splitBlocks.clear();
    }
162036
private void parseResources(Element element, BeanDefinitionBuilder builder,
                                ManagedList<AbstractBeanDefinition> resourceList) {
        NodeList resources = element.getChildNodes();

        for (int i = 0; i < resources.getLength(); i++) {
            Node node = resources.item(i);

            if (!(node instanceof Element)) {
                continue;
            }

            Element resource = (Element) resources.item(i);
            Class<? extends IPluginResource> resourceClass = null;

            switch (getResourceType(getNodeName(resource))) {
                case button:
                    resourceClass = PluginResourceButton.class;
                    break;
                
                case help:
                    resourceClass = PluginResourceHelp.class;
                    break;
                
                case menu:
                    resourceClass = PluginResourceMenu.class;
                    break;
                
                case property:
                    resourceClass = PluginResourcePropertyGroup.class;
                    break;
                
                case css:
                    resourceClass = PluginResourceCSS.class;
                    break;
                
                case bean:
                    resourceClass = PluginResourceBean.class;
                    break;
                
                case command:
                    resourceClass = PluginResourceCommand.class;
                    break;
                
                case action:
                    resourceClass = PluginResourceAction.class;
                    break;
            }

            if (resourceClass != null) {
                BeanDefinitionBuilder resourceBuilder = BeanDefinitionBuilder.genericBeanDefinition(resourceClass);
                addProperties(resource, resourceBuilder);
                resourceList.add(resourceBuilder.getBeanDefinition());
            }
        }
    }
1030534
@Override
    public void commitBlobBlocks(String blob, BlockList blockList)
            throws ServiceException {
        blobService.commitBlobBlocks(containerName, blob, blockList);
    }
228327
public void setEventSourceMappings(java.util.Collection<EventSourceMappingConfiguration> eventSourceMappings) {
        if (eventSourceMappings == null) {
            this.eventSourceMappings = null;
            return;
        }

        this.eventSourceMappings = new com.amazonaws.internal.SdkInternalList<EventSourceMappingConfiguration>(eventSourceMappings);
    }
32882
function updateBlocks(blocks) {
    for (var i = 0, block; block = blocks[i]; i++) {
      block.customUpdate && block.customUpdate();
    }
  }
360808
private static void mergeBlocks(List< Block > blocks) {
        for (int i = 1; i < blocks.size(); i++) {
            Block b1 = blocks.get(i - 1);
            Block b2 = blocks.get(i);
            if ((b1.mode == b2.mode) &&
                (b1.mode != EncodingMode.NUM || b1.length + b2.length <= MAX_NUMERIC_COMPACTION_BLOCK_SIZE)) {
                b1.length += b2.length;
                blocks.remove(i);
                i--;
            }
        }
    }
779257
private void processBlock(List<GenericCriteria> list, byte[] block)
   {
      if (block != null)
      {
         if (MPPUtility.getShort(block, 0) > 0x3E6)
         {
            addCriteria(list, block);
         }
         else
         {
            switch (block[0])
            {
               case (byte) 0x0B:
               {
                  processBlock(list, getChildBlock(block));
                  break;
               }

               case (byte) 0x06:
               {
                  processBlock(list, getListNextBlock(block));
                  break;
               }

               case (byte) 0xED: // EQUALS
               {
                  addCriteria(list, block);
                  break;
               }

               case (byte) 0x19: // AND
               case (byte) 0x1B:
               {
                  addBlock(list, block, TestOperator.AND);
                  break;
               }

               case (byte) 0x1A: // OR
               case (byte) 0x1C:
               {
                  addBlock(list, block, TestOperator.OR);
                  break;
               }
            }
         }
      }
   }
116905
@Override
  public void addBlock(BlockInfo newblock) {
    if (this.blocks == null) {
      this.blocks = new BlockInfo[1];
      this.blocks[0] = newblock;
    } else {
      int size = this.blocks.length;
      BlockInfo[] newlist = new BlockInfo[size + 1];
      System.arraycopy(this.blocks, 0, newlist, 0, size);
      newlist[size] = newblock;
      this.blocks = newlist;
    }
  }
1077684
public static SourceSet parse(String srcset, ErrorHandler errorHandler)
  {
    return new Parser(errorHandler).parse(srcset);
  }
917136
void addBlockToBeReplicated(Block block, DatanodeDescriptor[] targets) {
    assert(block != null && targets != null && targets.length > 0);
    replicateBlocks.offer(block, targets);
  }
1222016
function(source, type) {
  if (source.hasOwnProperty('format')) {
    if (source.format !== type) {
      if (source.format === 'section') {
        var blocks = [];
        source.blocks.forEach(function(val, index, array) {
          var block = deleteTextBlockFormat(val, type);
          if (block) {
            blocks.push(block);
          }
        });
        if (blocks.length) {
          return {format: 'section', blocks: blocks};
        } else {
          return null;
        }
      } else {
        return source;
      }
    } else {
      return null;
    }
  }
  throw new Error('invalid format for textblock (did you pass an Object in?)');
}
807691
protected void parseNames() {
        while (reader.hasNextCharacter()) {
            final char character = next();
            if (Strings.isWhitespace(character)) {
                addName();
                continue;
            } else if (character == blockOpening) {
                addName();
                break;
            } else {
                builder.append(character);
            }
        }
        if (GdxArrays.isEmpty(tags)) {
            throwException("No tag names chosen.");
        }
    }