Package org.eclipse.php.internal.core.format

Examples of org.eclipse.php.internal.core.format.IIndentationStrategy


            - (forOffset + command.length));
    final String trimedText = lineText.trim();

    final char insertionStrategyKey = trimedText.length() == 0 ? '{'
        : trimedText.charAt(0);
    final IIndentationStrategy indentationStrategy = getAutoEditStrategy(insertionStrategyKey);

    if (indentationStrategy instanceof IIndentationStrategyExtension1) {
      ((IIndentationStrategyExtension1) indentationStrategy)
          .placeMatchingBlanks(document, result, lineNumber,
              forOffset, getCurrentProgram(document));
    } else {
      indentationStrategy.placeMatchingBlanks(document, result,
          lineNumber, forOffset);
    }
  }
View Full Code Here


        final String trimedText = lineText.trim();

        final char insertionStrategyKey = trimedText.length() == 0
                ? '{'
                : trimedText.charAt(0);
        final IIndentationStrategy indentationStrategy = getAutoEditStrategy(insertionStrategyKey);

        indentationStrategy.placeMatchingBlanks(document, result, lineNumber,
                forOffset);
    }
View Full Code Here

            }

            // get regions
            final int startingWhiteSpaces = formattedLineStart
                    - orginalLineStart;
            final IIndentationStrategy insertionStrategy;
            final IStructuredDocumentRegion sdRegion = document
                    .getRegionAtCharacterOffset(formattedLineStart);
            ITextRegion firstTokenInLine = sdRegion
                    .getRegionAtCharacterOffset(formattedLineStart);
            int regionStart = sdRegion.getStartOffset(firstTokenInLine);
            if (firstTokenInLine instanceof ITextRegionContainer) {
                ITextRegionContainer container = (ITextRegionContainer) firstTokenInLine;
                firstTokenInLine = container
                        .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());
                }
            }

            // if the first char is not from this line
            if (firstTokenInLine == null)
                return;

            /*
             * if (firstTokenInLine.getStart() + sdRegion.getStartOffset() <
             * originalLineInfo.getOffset() || firstTokenInLine.getType() ==
             * PHPRegionTypes.WHITESPACE) { //meaning we got previos line last
             * token firstTokenInLine =
             * sdRegion.getRegionAtCharacterOffset(sdRegion.getStartOffset() +
             * firstTokenInLine.getEnd()); }
             */

            // if the next char is not from this line
            // if (firstTokenInLine == null)
            // return;

            String firstTokenType = firstTokenInLine.getType();
            /*
             * if (firstTokenType == TwigRegionTypes.TWIG_CONTENT) {
             * insertionStrategy = caseDefaultIndentationStrategy; } else
             */if (isTwigCommentRegion(firstTokenType)) {
                insertionStrategy = commentIndentationStrategy;
            } else if (firstTokenType == TwigRegionTypes.TWIG_CLOSETAG) {
                insertionStrategy = phpCloseTagIndentationStrategy;
            } else {
                insertionStrategy = getIndentationStrategy(lineText
                        .charAt(startingWhiteSpaces));
            }

            // Fill the buffer with blanks as if we added a "\n" to the end of
            // the prev element.
            // insertionStrategy.placeMatchingBlanks(editor,doc,insertionStrtegyKey,resultBuffer,startOffset-1);
            insertionStrategy.placeMatchingBlanks(document, resultBuffer,
                    lineNumber, document.getLineOffset(lineNumber));

            // replace the starting spaces
            final String newIndentation = resultBuffer.toString();
            final String oldIndentation = lineText.substring(0,
View Full Code Here

TOP

Related Classes of org.eclipse.php.internal.core.format.IIndentationStrategy

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.