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

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


     * @param tokenText token text
     * @return {@link IMXMLToken} instance
     */
    public static IMXMLToken create(int tokenType, int start, int end, int line, int column, CharSequence tokenText)
    {
        return new MXMLToken(tokenType, start, end, line, column, tokenText);
    }
View Full Code Here


    private void parse(MXMLData data, List<MXMLToken> tokens, MXMLDialect dialect, Collection<ICompilerProblem> problems)
    {
        ArrayList<MXMLUnitData> units = new ArrayList<MXMLUnitData>(tokens.size() / 6);
        nsMap = new HashMap<IMXMLTagData, PrefixMap>();
        MXMLUnitData unit = null;
        MXMLToken currentComment = null;
        FastStack<Integer> depth = new FastStack<Integer>(tokens.size() / 8);
        IFileSpecification spec = new FileSpecification(data.getPath() != null ? data.getPath() : "");
        depth.setStackDecorator(new IFastStackDecorator<Integer>() {
            @Override
            public Integer decorate(Integer e)
            {
                if (e == null)
                    return -1;
                return e;
            }

        });
        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.
View Full Code Here

        boolean foundTagEnd = false;
        boolean putTokenBack = false; // This is a pre-falcon algorithm that helped recover from tag nesting errors
                                      // I am bringing it back to life
        while (tokenIterator.hasNext() && !foundTagEnd)
        {
            MXMLToken token = tokenIterator.next();
            MXMLTagAttributeData attribute = null;
            switch (token.getType())
            {
                case MXMLTokenTypes.TOKEN_NAME:
                    if (nameType == MXMLTokenTypes.TOKEN_CLOSE_TAG_START)
                    {
                        problems.add(new SyntaxProblem(token));
                        //burn forward until the end tag
                        //TODO do we want to mark each token as an error, or just the first?
                        while (tokenIterator.hasNext() && !foundTagEnd)
                        {
                            token = tokenIterator.next();
                            switch (token.getType())
                            {
                                case MXMLTokenTypes.TOKEN_TAG_END:
                                case MXMLTokenTypes.TOKEN_EMPTY_TAG_END:
                                    foundTagEnd = true;
                                    break;
                            }
                        }
                        break;
                    }
                    if (token.getText().startsWith("xmlns"))
                    {
                        attribute = new MXMLNamespaceAttributeData(token, tokenIterator, dialect, spec, problems);
                        if (map == null)
                            map = new MutablePrefixMap();
                        map.add(((IMXMLNamespaceAttributeData)attribute).getNamespacePrefix(), ((IMXMLNamespaceAttributeData)attribute).getNamespace());
                    }
                    else
                    {
                        attribute = new MXMLTagAttributeData(token, tokenIterator, dialect, spec, problems);
                    }
                    attribute.setParent(this);
                    // add the attribute to the attributes list even if it is duplicate
                    // otherwise code-hinting will not work properly
                    if (attributeMap.containsKey(token.getText()))
                    {
                        MXMLDuplicateAttributeProblem problem = new MXMLDuplicateAttributeProblem(attribute);
                        problems.add(problem);
                    }
                    attrs.add(attribute);
                    attributeMap.put(token.getText(), attribute);

                    // Now advance the offsets to include the newly parsed attributes
                    contentEnd = attribute.getAbsoluteEnd();
                    setTagOffsets(startOffset, contentEnd, nameStart, contentEnd);
                    break;
                case MXMLTokenTypes.TOKEN_TAG_END:
                    foundTagEnd = true;
                    explicitCloseToken = !token.isImplicit();
                    break;
                case MXMLTokenTypes.TOKEN_EMPTY_TAG_END:
                    emptyTag = true;
                    explicitCloseToken = !token.isImplicit();
                    foundTagEnd = true;
                    break;
                case MXMLTokenTypes.TOKEN_OPEN_TAG_START:
                case MXMLTokenTypes.TOKEN_CLOSE_TAG_START:
                    problems.add(new SyntaxProblem(token));
                    foundTagEnd = true; // Don't keep going - bail from malformed tag
                    putTokenBack = true;

                    // if we added   this.fEmptyTag = true; then we could repair the damage here,
                    // but it's better to let the balancer repair it (in case there is a matching close lurking somewhere)
                    break;
                default:
                    problems.add(new SyntaxProblem(token));
                    break;
            }
            if (foundTagEnd)
            {
                if (token.isImplicit() && token.getStart() == -1)
                {
                    explicitCloseToken = false;
                    //let's try to end at the start of the next token if one exists
                    if (tokenIterator.hasNext())
                    {
                        MXMLToken next = tokenIterator.next();
                        if (next != null)
                        {
                            // extend the end, but not the content end
                            setTagOffsets(getAbsoluteStart() == -1 ? next.getStart() : getAbsoluteStart(), getAbsoluteEnd() == -1 ? next.getStart() : getAbsoluteEnd(), nameStart == -1 ? next.getStart() : nameStart, contentEnd == -1 ? next.getStart() : contentEnd);
                            tokenIterator.previous();
                        }
                    }
                    else
                    {
View Full Code Here

        {
            stateName = splitState.getStateName();
            stateStart = nameToken.getStart() + splitState.getStateNameOffset();
        }

        MXMLToken token = null;

        // Look for "=" token.
        if (tokenIterator.hasNext())
        {
            token = tokenIterator.next();

            if (token.getType() != MXMLTokenTypes.TOKEN_EQUALS)
            {
                problems.add(new SyntaxProblem(token));
                // Restore the token position for error recovery.
                tokenIterator.previous();
                return;
            }

            valueStart = token.getEnd() + 1; // set the value's start to right after the equals until we have a value
            valueLine = token.getLine();
            valueColumn = token.getColumn();
        }

        // Look for value token.
        while (tokenIterator.hasNext())
        {
            token = tokenIterator.next();
            if (token.getType() == MXMLTokenTypes.TOKEN_STRING)
            {
                valueIncludingDelimiters = token.getText();
            }
            else
            {
                if (!MXMLToken.isTagEnd(token.getType()) && token.getType() != MXMLTokenTypes.TOKEN_NAME)
                    problems.add(new SyntaxProblem(token));
                // Restore the token position for error recovery.
                tokenIterator.previous();
                return;
            }
View Full Code Here

TOP

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

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.