Package com.dubture.twig.core.documentModel.parser.regions

Examples of com.dubture.twig.core.documentModel.parser.regions.ITwigScriptRegion


                tRegion = container.getRegionAtCharacterOffset(offset);
                regionStart += tRegion.getStart();
            }

            if (tRegion != null && tRegion instanceof ITwigScriptRegion) {
                ITwigScriptRegion scriptRegion = (ITwigScriptRegion) tRegion;
                int regionOffset = offset - regionStart;
                ITextRegion innerRegion = scriptRegion
                        .getTwigToken(regionOffset);
                return innerRegion.getType();
            }
        } catch (final BadLocationException e) {
        } catch (final Exception e1) {
View Full Code Here


                tRegion = container.getRegionAtCharacterOffset(offset);
                regionStart += tRegion.getStart();
            }

            if (tRegion != null && tRegion instanceof ITwigScriptRegion) {
                ITwigScriptRegion scriptRegion = (ITwigScriptRegion) tRegion;
                int regionOffset = offset - regionStart;
                ITextRegion innerRegion = scriptRegion
                        .getTwigToken(regionOffset);
                String partition = scriptRegion.getPartition(regionOffset);
                // check if the offset is in the start of the php token
                // because if so this means we're at PHP_DEFAULT partition type
                if (offset
                        - (sdRegion.getStart() + regionStart + innerRegion
                                .getStart()) == 0) {
View Full Code Here

            tRegion = container.getRegionAtCharacterOffset(offset);
            regionStart += tRegion.getStart();
        }

        if (tRegion instanceof ITwigScriptRegion) {
            ITwigScriptRegion scriptRegion = (ITwigScriptRegion) tRegion;
            tRegion = scriptRegion.getTwigToken(offset - regionStart);

            if (tRegion == null)
                return null;

            // go backward over the region to find a region (not comment nor
            // whitespace)
            // in the same line
            do {
                String token = tRegion.getType();
                if (regionStart + tRegion.getStart() >= forOffset) {
                    // making sure the region found is not after the caret
                    // (https://bugs.eclipse.org/bugs/show_bug.cgi?id=222019 -
                    // caret before '{')
                } else if (!TwigPartitionTypes.isTwigCommentState(token)
                        && token != TwigRegionTypes.WHITESPACE) {
                    // not comment nor white space
                    return tRegion;
                }
                tRegion = scriptRegion.getTwigToken(tRegion.getStart() - 1);
            } while (tRegion != null
                    && tRegion.getStart() + regionStart > lineStartOffset);
        }

        return null;
View Full Code Here

                        .getRegionAtCharacterOffset(lineStart);
                phpContentStartOffset += phpScriptRegion.getStart();
            }

            if (phpScriptRegion instanceof ITwigScriptRegion) {
                ITwigScriptRegion scriptRegion = (ITwigScriptRegion) phpScriptRegion;
                // the region we are trying to check if it is the indent base
                // for the line we need to format
                ContextRegion checkedRegion = (ContextRegion) scriptRegion
                        .getTwigToken(lineStart - phpContentStartOffset);
                // the current region we need to format
                ContextRegion currentRegion = (ContextRegion) scriptRegion
                        .getTwigToken(forOffset - phpContentStartOffset);
                String checkedType = checkedRegion.getType();
                String currentType = currentRegion.getType();
                // if we are in the beginning of a comment (DOC or Multi
                // comment) and we have before another
View Full Code Here

        }

        // This text region must be of type PhpScriptRegion:
        if (tRegion != null
                && TwigTextSequenceUtilities.isTwigRegion(tRegion.getType())) {
            ITwigScriptRegion twigScriptRegion = (ITwigScriptRegion) tRegion;

            try {
                // Set default starting position to the beginning of the
                // PhpScriptRegion:
                int startOffset = container.getStartOffset()
                        + twigScriptRegion.getStart();

                // Now, search backwards for the statement start (in this
                // PhpScriptRegion):
                ITextRegion startTokenRegion;
                if (documentOffset == startOffset) {
                    startTokenRegion = twigScriptRegion.getTwigToken(0);
                } else {
                    startTokenRegion = twigScriptRegion.getTwigToken(offset
                            - startOffset - 1);
                }
                while (true) {
                    // If statement start is at the beginning of the PHP script
                    // region:
                    if (startTokenRegion.getStart() == 0) {
                        break;
                    }

                    if (startTokenRegion.getType() == PHPRegionTypes.PHP_CURLY_CLOSE
                            || startTokenRegion.getType() == PHPRegionTypes.PHP_CURLY_OPEN
                            || startTokenRegion.getType() == PHPRegionTypes.PHP_SEMICOLON) {
                        // Calculate starting position of the statement (it
                        // should go right after this startTokenRegion):
                        startOffset += startTokenRegion.getEnd();
                        break;
                    }
                    startTokenRegion = twigScriptRegion
                            .getTwigToken(startTokenRegion.getStart() - 1);
                }

                TextSequence textSequence = TextSequenceUtilities
                        .createTextSequence(sdRegion, startOffset, offset
View Full Code Here

TOP

Related Classes of com.dubture.twig.core.documentModel.parser.regions.ITwigScriptRegion

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.