Package org.apache.flex.compiler.mxml

Examples of org.apache.flex.compiler.mxml.IMXMLUnitData


    }

    @Override
    public final IMXMLUnitData getNextSiblingUnit()
    {
        IMXMLUnitData unit = this;

        if (isOpenAndNotEmptyTag())
            unit = ((IMXMLTagData)unit).findMatchingEndTag();

        if (unit != null)
        {
            unit = unit.getNext();

            if (unit != null && (unit.getParentUnitData() != getParentUnitData()))
                unit = null;
        }
        return unit;
    }
View Full Code Here


    }

    @Override
    public final IMXMLTagData getNextTag()
    {
        IMXMLUnitData nextUnit = getNext();

        while (true)
        {
            if (nextUnit == null)
                return null;

            if (nextUnit.isTag())
                return (IMXMLTagData)nextUnit;

            nextUnit = nextUnit.getNext();
        }
    }
View Full Code Here

    @Override
    public final IMXMLTagData getContainingTag(int offset)
    {
        FastStack<String> tagNames = new FastStack<String>();
        IMXMLUnitData current = getPrevious();
        IMXMLTagData containingTag = null;

        if (containsOffset(offset) && isCloseTag())
        {
            IMXMLTagData tag = (IMXMLTagData)this;
            tagNames.push(tag.getName());
        }

        while (current != null && containingTag == null)
        {
            if (current.isTag())
            {
                IMXMLTagData currentTag = (IMXMLTagData)current;

                if (currentTag.isCloseTag())
                {
                    tagNames.push(currentTag.getName());
                }
                else if (currentTag.isOpenTag() && !currentTag.isEmptyTag())
                {
                    String stackName = "";
                    while (stackName.compareTo(currentTag.getName()) != 0 && !tagNames.isEmpty())
                    {
                        stackName = tagNames.pop();
                    }
                    if (stackName.compareTo(currentTag.getName()) != 0)
                        containingTag = currentTag;
                }
            }

            current = current.getPrevious();
        }

        return containingTag;
    }
View Full Code Here

        // Sanity check
        if (startOffset < 0 || startOffset >= units.length)
            startOffset = 0;

        // Now iterate though the units and find the first one that is acceptable
        IMXMLUnitData ret = null;
        for (int i = startOffset; (i < units.length) && (ret == null); i++)
        {
            IMXMLUnitData unit = units[i];

            // unit is a match if it "contains" the offset.
            // We are using a somewhat bizarre form of "contains" here, in that we are
            // using getStart() and getConentEnd(). This asymmetric mismatch is for several reasons:
            //      * it's the only way to match the existing (non-falcon) behavior
            //      * If our cursor is before the <, we want to match the tag.
            //              example:     |<foo   >  will find "foo" as the nearest tag.
            //      So we need to use start here (not content start)
            //      * If our cursor is between two tags, we want to match the NEXT one, not the previous one
            //              example:   <bar >|<foo>  should match foo, not bar

            if (MXMLData.contains(unit.getAbsoluteStart(), unit.getContentEnd(), offset))
            {
                ret = unit;
            }
            // if we find a unit that starts after the offset, then it must
            // be the "first one after", so return it
            else if (unit.getAbsoluteStart() >= offset)
            {
                ret = unit;
            }
        }

View Full Code Here

     * @param offset test offset
     * @return the containing unit (or null if no unit contains this offset)
     */
    public IMXMLUnitData findUnitContainingOffset(int offset)
    {
        IMXMLUnitData unit = findNearestUnit(offset);
        if (unit != null && unit.containsOffset(offset))
            return unit;

        return null;
    }
View Full Code Here

     * @param offset test offset
     * @return the containing tag (or null, if no tag contains this offset)
     */
    public IMXMLTagData findTagContainingOffset(int offset)
    {
        IMXMLUnitData unit = findUnitContainingOffset(offset);
        if (unit != null && unit.isTag())
            return (IMXMLTagData)unit;

        return null;
    }
View Full Code Here

    }

    @Override
    public IMXMLTagData findTagOrSurroundingTagContainingOffset(int offset)
    {
        IMXMLUnitData unit = findUnitContainingOffset(offset);
        if (unit != null)
        {
            if (unit.isTag())
            {
                return (IMXMLTagData)unit;
            }
            else if (unit.isText())
            {
                IMXMLTagData containingTag = unit.getContainingTag(unit.getAbsoluteStart());
                return containingTag;
            }
        }

        return null;
View Full Code Here

    public IMXMLTagData getRootTag()
    {
        int n = units.length;
        for (int i = 0; i < n; i++)
        {
            IMXMLUnitData unit = units[i];
            if (unit instanceof IMXMLTagData)
                return (IMXMLTagData)unit;
        }
        return null;
    }
View Full Code Here

            // Script tags are put in the defaultPropertyContentUnits collection
            // to fix http://bugs.adobe.com/jira/browse/CMP-955.
            int lastNonScriptTagIndex;
            for (lastNonScriptTagIndex = (defaultPropertyContentUnits.size() - 1); lastNonScriptTagIndex > 0; --lastNonScriptTagIndex)
            {
                IMXMLUnitData unitData = defaultPropertyContentUnits.get(lastNonScriptTagIndex);
                if (!builder.getFileScope().isScriptTag(unitData))
                    break;
            }
            assert lastNonScriptTagIndex >= 0;
            assert lastNonScriptTagIndex < defaultPropertyContentUnits.size();
View Full Code Here

*/
public class MXMLTextDataTests extends MXMLUnitDataTests
{
  private IMXMLTextData getMXMLTextData(String[] code)
  {
    IMXMLUnitData unitData = getMXMLUnitData(code);
    assertThat("instanceOf", unitData, is(instanceOf(IMXMLTextData.class)));
    return (IMXMLTextData)unitData;
  }
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.mxml.IMXMLUnitData

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.