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

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


                || sdRegion.getType() != TwigRegionTypes.TWIG_CONTENT
                || sdRegion.getRegions().size() < 2) {
            return null;
        }

        final ITwigScriptRegion textRegion = (ITwigScriptRegion) sdRegion
                .getRegions().get(1);
        try {
            ITextRegion phpToken = textRegion.getTwigToken(0);
            i = 0;
            while (phpToken != null
                    && phpToken.getType() != /*
                                              * PHPRegionTypes.PHPDOC_COMMENT_START
                                              */TwigRegionTypes.TWIG_COMMENT_TEXT
                    && i++ < 3) {
                phpToken = textRegion.getTwigToken(phpToken.getEnd() + 1);
            }
            if (phpToken == null
                    || phpToken.getType() != /*
                                              * PHPRegionTypes.PHPDOC_COMMENT_START
                                              */TwigRegionTypes.TWIG_COMMENT_TEXT) {
                return null;
            }
            int start = phpToken.getStart();
            ITextRegion lastToken = null;
            while (lastToken != phpToken
                    && phpToken != null
                    && phpToken.getType() != /*
                                              * PHPRegionTypes.PHPDOC_COMMENT_END
                                              */TwigRegionTypes.TWIG_COMMENT_TEXT) {
                phpToken = textRegion.getTwigToken(phpToken.getEnd() + 1);
            }

            if (phpToken != null
                    && phpToken.getType() == /*
                                              * PHPRegionTypes.PHPDOC_COMMENT_END
                                              */TwigRegionTypes.TWIG_COMMENT_TEXT) {
                int end = phpToken.getEnd();
                return new Region(sdRegion.getStartOffset()
                        + textRegion.getStart() + start, end - start);
            }
            return null;

        } catch (BadLocationException e) {
            return null;
View Full Code Here


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

        if (tRegion instanceof ITwigScriptRegion) {
            ITwigScriptRegion scriptRegion = (ITwigScriptRegion) tRegion;
            tRegion = scriptRegion.getTwigToken(offset - regionStart);
            return tRegion;
        }
        return null;
    }
View Full Code Here

            ITextRegionContainer container = (ITextRegionContainer) tRegion;
            tRegion = container.getRegionAtCharacterOffset(offset);
            regionStart += tRegion.getStart();
        }
        if (tRegion instanceof ITwigScriptRegion) {
            ITwigScriptRegion scriptRegion = (ITwigScriptRegion) tRegion;
            tRegion = scriptRegion.getTwigToken(offset - regionStart);
            regionStart += tRegion.getStart();
        }
        return regionStart;
    }
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
                        || tRegion.getType() != TwigRegionTypes.TWIG_CONSTANT_ENCAPSED_STRING) {
                    return;
                }
View Full Code Here

                    regionStart += tRegion.getStart();
                }

                if (tRegion instanceof ITwigScriptRegion) {

                    ITwigScriptRegion scriptRegion = (ITwigScriptRegion) tRegion;
                    tRegion = scriptRegion.getTwigToken(currOffset
                            - regionStart);

                    while (tRegion != null) {

                        String regionType = tRegion.getType();

                        if (regionType == TwigRegionTypes.TWIG_DELIMITER) {

                            char token = document.getChar(regionStart
                                    + tRegion.getStart());
                            if (token == ROUND_OPEN || token == SQUARE_OPEN
                                    || token == CURLY_OPEN) {
                                if (token == bracketChar) {
                                    if (matcher.match(document, regionStart
                                            + tRegion.getStart() + 1) == null) {
                                        return MATCHING_BRACKET_NEEDED;
                                    }
                                }
                            }
                        } else if (regionType == PHPRegionTypes.PHP_CURLY_OPEN
                                || regionType == PHPRegionTypes.PHP_CURLY_CLOSE
                                || regionType == TwigRegionTypes.TWIG_HASH_END) {
                            return MATCHING_BRACKET_NOT_NEEDED;
                        } else if (regionType == TwigRegionTypes.TWIG_HASH_START) {
                            return MATCHING_BRACKET_NEEDED;
                        }

                        if (tRegion.getStart() > 0) {
                            tRegion = scriptRegion.getTwigToken(tRegion
                                    .getStart() - 1);
                        } else {
                            break;
                        }
                    }
View Full Code Here

                container = (ITextRegionContainer) interest;
                interest = container.getRegionAtCharacterOffset(offset);
            }

            if (interest.getType() == TwigRegionContext.TWIG_CONTENT) {
                ITwigScriptRegion phpScript = (ITwigScriptRegion) interest;
                try {
                    regionContext = phpScript
                            .getTwigTokenType(offset
                                    - container.getStartOffset()
                                    - phpScript.getStart());
                } catch (BadLocationException e) {
                    assert false;
                    return null;
                }
            } else if (interest.getType() == TwigRegionContext.TWIG_STMT_OPEN) {
View Full Code Here

                    regionStart += tRegion.getStart();
                }

                if (tRegion instanceof ITwigScriptRegion) {

                    ITwigScriptRegion scriptRegion = (ITwigScriptRegion) tRegion;
                    tRegion = scriptRegion.getTwigToken(currOffset
                            - regionStart);

                    while (tRegion != null) {

                        String regionType = tRegion.getType();

                        if (regionType == TwigRegionTypes.TWIG_DELIMITER) {

                            char token = document.getChar(regionStart
                                    + tRegion.getStart());
                            if (token == ROUND_OPEN || token == SQUARE_OPEN
                                    || token == CURLY_OPEN) {
                                if (token == bracketChar) {
                                    if (matcher.match(document, regionStart
                                            + tRegion.getStart() + 1) == null) {
                                        return MATCHING_BRACKET_NEEDED;
                                    }
                                }
                            }
                        } else if (regionType == PHPRegionTypes.PHP_CURLY_OPEN
                                || regionType == PHPRegionTypes.PHP_CURLY_CLOSE
                                || regionType == TwigRegionTypes.TWIG_HASH_END) {
                            return MATCHING_BRACKET_NOT_NEEDED;
                        } else if (regionType == TwigRegionTypes.TWIG_HASH_START) {
                            return MATCHING_BRACKET_NEEDED;
                        }

                        if (tRegion.getStart() > 0) {
                            tRegion = scriptRegion.getTwigToken(tRegion
                                    .getStart() - 1);
                        } else {
                            break;
                        }
                    }
View Full Code Here

                ITextRegionContainer container = (ITextRegionContainer) tRegion;
                tRegion = container.getRegionAtCharacterOffset(offset);
            }

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

                if (tRegion == null
                        || (tRegion.getType() != TwigRegionTypes.TWIG_DELIMITER && tRegion
                                .getType() != TwigRegionTypes.TWIG_HASH_START)) {
View Full Code Here

                        .getRegionAtCharacterOffset(formattedLineStart);
                regionStart += firstTokenInLine.getStart();
            }

            if (firstTokenInLine instanceof ITwigScriptRegion) {
                ITwigScriptRegion scriptRegion = (ITwigScriptRegion) firstTokenInLine;
                firstTokenInLine = scriptRegion.getTwigToken(formattedLineStart
                        - regionStart);
                if (firstTokenInLine != null
                        && firstTokenInLine.getStart()
                                + sdRegion.getStartOffset() < orginalLineStart
                        && firstTokenInLine.getType() == TwigRegionTypes.WHITESPACE) {
                    firstTokenInLine = scriptRegion
                            .getTwigToken(formattedLineStart - regionStart
                                    + firstTokenInLine.getLength());
                }
            }
View Full Code Here

            tRegion = container.getRegionAtCharacterOffset(offset);
            regionStart += tRegion.getStart();
        }
        do {
            if (tRegion instanceof ITwigScriptRegion) {
                ITwigScriptRegion scriptRegion = (ITwigScriptRegion) tRegion;
                tRegion = scriptRegion.getTwigToken(offset - regionStart - 1);

                // go backward over the region to find a 'case' or 'default'
                // region
                // in this case is the same indentation
                // other case if look for the '{' of the 'switch' region
                while (tRegion != null) {
                    String token = tRegion.getType();
                    if (token == PHPRegionTypes.PHP_CURLY_OPEN) {
                        curlyCount--;
                        if (curlyCount < 0) {
                            return document.getLineInformationOfOffset(tRegion
                                    .getStart() + regionStart);
                        }
                    } else if (token == PHPRegionTypes.PHP_CURLY_CLOSE) {
                        curlyCount++;
                    }
                    if (tRegion.getStart() > 0) {
                        tRegion = scriptRegion
                                .getTwigToken(tRegion.getStart() - 1);
                    } else {
                        break;
                    }
                }
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.