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

Examples of org.apache.flex.compiler.internal.parsing.as.OffsetLookup


        // When parsing the MXML for AST construction, ad-hoc IncludeHandler are created in
        // order to please the MXML lexer and to keep the AST node offsets in-sync with
        // the scope tree node offsets. As a result, the MXML AST nodes does not have a
        // usable OffsetLookup after tree building. That's why we need to provide the real
        // OffsetLookup from the scope building.
        final OffsetLookup offsetLookup = fileScope.getOffsetLookup();
        assert offsetLookup != null : "Expected offset lookup on MXMLFileScope.";
        this.offsetLookup = offsetLookup;

        setLocation(builder);
View Full Code Here


    public void adjustOffsets(MXMLTreeBuilder builder)
    {
        final MXMLFileScope fileScope = builder.getFileScope();
        assert fileScope != null : "Expected MXMLFileScope.";

        final OffsetLookup offsetLookup = fileScope.getOffsetLookup();
        assert offsetLookup != null : "Expected OffsetLookup on file scope.";

        final String path = getFileSpecification().getPath(); // TODO Get from builder?

        final int absoluteStart = offsetLookup.getAbsoluteOffset(path, getAbsoluteStart())[0];
        final int absoluteEnd = offsetLookup.getAbsoluteOffset(path, getAbsoluteEnd())[0];
        setStart(absoluteStart);
        setEnd(absoluteEnd);
    }
View Full Code Here

        }

        public ISourceFragment[] getSourceFragments()
        {
            final MXMLFileScope fileScope = builder.getFileScope();
            final OffsetLookup offsetLookup = fileScope.getOffsetLookup();
            assert offsetLookup != null : "Expected OffsetLookup on FileScope.";
            for (ISourceFragment fragment : sourceFragmentList)
            {
                int physicalStart = fragment.getPhysicalStart();
                final int[] absoluteOffsets = offsetLookup.getAbsoluteOffset(sourcePath, physicalStart);
                ((SourceFragment)fragment).setPhysicalStart(absoluteOffsets[0]);
            }

            return sourceFragmentList.toArray(new ISourceFragment[0]);
        }
View Full Code Here

                {
                    final IncludeHandler includeHandler = new IncludeHandler(builder.getFileSpecificationGetter());
                    includeHandler.setProjectAndCompilationUnit(project, builder.getCompilationUnit());
                    includeHandler.enterFile(sourcePath);
                    final MXMLFileScope fileScope = builder.getFileScope();
                    final OffsetLookup offsetLookup = fileScope.getOffsetLookup();
                    assert offsetLookup != null : "Expected OffsetLookup on FileScope.";
                    final int[] absoluteOffset = offsetLookup.getAbsoluteOffset(sourcePath, 0);

                    final ScopedBlockNode fragment = ASParser.parseFragment2(
                            scriptText,
                            sourceFileSpec.getPath(),
                            absoluteOffset[0],
View Full Code Here

        final MXMLDialect mxmlDialect = builder.getMXMLDialect();
        final String sourcePath = tag.getParent().getFileSpecification().getPath();
        final MXMLClassDefinitionNode classNode = getContainingClassNode();
        final ASScope classScope = (ASScope)classNode.getClassDefinition().getContainedScope();
        final CompilerProject project = builder.getProject();
        final OffsetLookup offsetLookup = classScope.getFileScope().getOffsetLookup();

        setSourcePath(sourcePath);
        try
        {
            // parse inline ActionScript
            final List<ScopedBlockNode> scriptNodes = new ArrayList<ScopedBlockNode>();
            for (IMXMLUnitData unit = tag.getFirstChildUnit(); unit != null; unit = unit.getNextSiblingUnit())
            {
                if (unit instanceof IMXMLTextData)
                {
                    final IMXMLTextData mxmlTextData = (IMXMLTextData)unit;
                    String text = mxmlTextData.getCompilableText();
                    if (!mxmlDialect.isWhitespace(text))
                    {
                        // local offset at the end of the containing open script tag
                        assert offsetLookup != null : "Expected OffsetLookup on FileScope.";
                        final int localOffset = mxmlTextData.getParentUnitData().getAbsoluteEnd();
                        final int[] absoluteOffsets = offsetLookup.getAbsoluteOffset(sourcePath, localOffset);
                        final int absoluteOffset = absoluteOffsets[0];

                        // create an include handler and mock its state as if it is
                        // before parsing for scope building
                        final IncludeHandler includeHandler = IncludeHandler.createForASTBuilding(
View Full Code Here

            final IMXMLData mxmlData = getMXMLData();
                   
            final MXMLScopeBuilder scopeBuilder = new MXMLScopeBuilder(this, getFileSpecificationGetter(), mxmlData, qname, getAbsoluteFilename());
            MXMLFileScope fileScope = scopeBuilder.build();
            final ImmutableList<OffsetCue> offsetCueList = scopeBuilder.getIncludeHandler().getOffsetCueList();
            final OffsetLookup offsetLookup = new OffsetLookup(offsetCueList);
            fileScope.setOffsetLookup(offsetLookup);
            final Collection<ICompilerProblem> problemCollection = scopeBuilder.getProblems();
            final IFileSpecification rootFileSpec = getRootFileSpecification();

            getProject().getWorkspace().addIncludedFilesToCompilationUnit(this, fileScope.getSourceDependencies());
View Full Code Here

    }

    @Override
    public int getStart()
    {
        OffsetLookup offsetLookup = getOffsetLookup();

        if (offsetLookup == null)
            return absoluteStart;

        return offsetLookup.getLocalOffset(absoluteStart);
    }
View Full Code Here

    }

    @Override
    public int getEnd()
    {
        OffsetLookup offsetLookup = getOffsetLookup();

        if (offsetLookup == null)
            return absoluteEnd;

        return offsetLookup.getLocalOffset(absoluteEnd);
    }
View Full Code Here

        final int absoluteStart = nodeRef.getAbsoluteStart();
        if (absoluteStart == UNKNOWN)
            return UNKNOWN;

        final OffsetLookup offsetLookup = getOffsetLookup();
        if (offsetLookup == null)
            return absoluteStart;

        return offsetLookup.getLocalOffset(absoluteStart);
    }
View Full Code Here

    public int getNameStart()
    {
        if (absoluteNameStart == UNKNOWN)
            return UNKNOWN;

        OffsetLookup offsetLookup = getOffsetLookup();
        if (offsetLookup == null)
            return absoluteNameStart;

        return offsetLookup.getLocalOffset(absoluteNameStart);
    }
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.internal.parsing.as.OffsetLookup

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.