Package org.apache.flex.compiler.internal.parsing.mxml

Examples of org.apache.flex.compiler.internal.parsing.mxml.BalancingMXMLProcessor


        });
        int index = -1;
        int balancingIndex = 0;
        depth.push(index);
        ListIterator<MXMLToken> tokenIterator = tokens.listIterator();
        BalancingMXMLProcessor processor = new BalancingMXMLProcessor(getFileSpecification(), problems);
        while (tokenIterator.hasNext())
        {
            MXMLToken token = tokenIterator.next();
            switch (token.getType())
            {
                case MXMLTokenTypes.TOKEN_ASDOC_COMMENT:
                {
                    currentComment = token;
                    //treat this like text.
                    unit = new MXMLTextData(token);
                    units.add(unit);
                    index++;
                    if (fullContent)
                    {
                        unit.setParentUnitDataIndex(depth.peek());
                        unit.setLocation(data, index);
                    }
                    break;
                }
               
                case MXMLTokenTypes.TOKEN_COMMENT:
                case MXMLTokenTypes.TOKEN_CDATA:
                case MXMLTokenTypes.TOKEN_WHITESPACE:
                {
                    //treat this like text.
                    unit = new MXMLTextData(token);
                    units.add(unit);
                    index++;
                    if (fullContent)
                    {
                        unit.setParentUnitDataIndex(depth.peek());
                        unit.setLocation(data, index);
                    }
                    break;
                }
               
                case MXMLTokenTypes.TOKEN_OPEN_TAG_START:
                {
                    unit = new MXMLTagData();
                    MutablePrefixMap map = ((MXMLTagData)unit).init(this, token, tokenIterator, dialect, spec, problems);
                    ((MXMLTagData)unit).setCommentToken(currentComment);
                    currentComment = null;
                    units.add(unit);
                    index++;
                    if (fullContent)
                    {
                        unit.setParentUnitDataIndex(depth.peek());
                        unit.setLocation(data, index);
                        if (!((MXMLTagData)unit).isEmptyTag())
                            processor.addOpenTag((MXMLTagData)unit, balancingIndex);
                    }
                    if (map != null)
                        nsMap.put((MXMLTagData)unit, map.toImmutable());
                    if (!((MXMLTagData)unit).isEmptyTag())
                    {
                        depth.push(index);
                        balancingIndex++;
                    }
                    break;
                }
               
                case MXMLTokenTypes.TOKEN_CLOSE_TAG_START:
                {
                    unit = new MXMLTagData();
                    ((MXMLTagData)unit).init(this, token, tokenIterator, dialect, spec, problems);
                    ((MXMLTagData)unit).setCommentToken(currentComment);
                    if (!((MXMLTagData)unit).isEmptyTag())
                    {
                        depth.pop();
                        balancingIndex--;
                    }
                    index++;
                    if (fullContent)
                    {
                        unit.setLocation(data, index);
                        unit.setParentUnitDataIndex(depth.peek());
                        processor.addCloseTag((MXMLTagData)unit, balancingIndex);
                    }
                    currentComment = null;
                    units.add(unit);
                    break;
                }
               
                case MXMLTokenTypes.TOKEN_TEXT:
                {
                    unit = new MXMLTextData(token);
                    units.add(unit);
                    index++;
                    if (fullContent)
                    {
                        unit.setParentUnitDataIndex(depth.peek());
                        unit.setLocation(data, index);
                    }
                    break;
                }
               
                case MXMLTokenTypes.TOKEN_PROCESSING_INSTRUCTION:
                {
                    unit = new MXMLInstructionData(token);
                    units.add(unit);
                    index++;
                    if (fullContent)
                    {
                        unit.setParentUnitDataIndex(depth.peek());
                        unit.setLocation(data, index);
                    }
                    break;
                }
               
                default:
                {
                    problems.add(new SyntaxProblem(token));
                    break;
                }
            }
        }
        this.units = units.toArray(new IMXMLUnitData[0]);
        if (fullContent && shouldRepair)
        {
            this.units = processor.balance(this.units, this, nsMap);
            if (processor.wasRepaired())
            { //repaired, so let's rebuild our prefix maps and tag depths
                refreshPositionData();
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.internal.parsing.mxml.BalancingMXMLProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.