Package org.eclipse.php.internal.core.documentModel.parser.regions

Examples of org.eclipse.php.internal.core.documentModel.parser.regions.IPhpScriptRegion


    }

    // This text region must be of type PhpScriptRegion:
    if (tRegion != null
        && tRegion.getType() == PHPRegionContext.PHP_CONTENT) {
      IPhpScriptRegion phpScriptRegion = (IPhpScriptRegion) tRegion;

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

        // Now, search backwards for the statement start (in this
        // PhpScriptRegion):
        ITextRegion startTokenRegion;
        if (documentOffset == startOffset) {
          startTokenRegion = phpScriptRegion.getPhpToken(0);
        } else {
          startTokenRegion = phpScriptRegion.getPhpToken(offset
              - startOffset - 1);
        }
        // If statement start is at the beginning of the PHP script
        // region:
        while (true) {
          if (startTokenRegion.getStart() == 0) {
            return NONE;
          }
          if (startTokenRegion.getType() != PHPRegionTypes.PHP_LINE_COMMENT
              && startTokenRegion.getType() != PHPRegionTypes.PHP_COMMENT
              && startTokenRegion.getType() != PHPRegionTypes.WHITESPACE
              && !startTokenRegion.getType().startsWith("PHPDOC")) { //$NON-NLS-1$
            types.add(startTokenRegion.getType());
          }
          if (startTokenRegion.getType() == PHPRegionTypes.PHP_CURLY_OPEN
              || startTokenRegion.getType() == PHPRegionTypes.PHP_INSTEADOF
              || startTokenRegion.getType() == PHPRegionTypes.PHP_SEMICOLON
              || startTokenRegion.getType() == PHPRegionTypes.PHP_AS) {
            break;
          }

          startTokenRegion = phpScriptRegion
              .getPhpToken(startTokenRegion.getStart() - 1);
        }

      } catch (BadLocationException e) {
      }
View Full Code Here


    }

    // This text region must be of type PhpScriptRegion:
    if (tRegion != null
        && tRegion.getType() == PHPRegionContext.PHP_CONTENT) {
      IPhpScriptRegion phpScriptRegion = (IPhpScriptRegion) tRegion;

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

        // Now, search backwards for the statement start (in this
        // PhpScriptRegion):
        ITextRegion startTokenRegion;
        if (documentOffset == startOffset) {
          startTokenRegion = phpScriptRegion.getPhpToken(0);
        } else {
          startTokenRegion = phpScriptRegion.getPhpToken(offset
              - startOffset - 1);
        }
        // If statement start is at the beginning of the PHP script
        // region:
        while (true) {
          if (startTokenRegion.getStart() == 0) {
            return false;
          }
          if (startTokenRegion.getType() == PHPRegionTypes.PHP_CURLY_OPEN) {
            // Calculate starting position of the statement (it
            // should go right after this startTokenRegion):
            // startOffset += startTokenRegion.getEnd();
            TextSequence statementText1 = getStatementText(startOffset
                + startTokenRegion.getStart() - 1);
            startTokenRegion = phpScriptRegion
                .getPhpToken(startTokenRegion.getStart()
                    - statementText1.length());
            if (startTokenRegion != null
                && startTokenRegion.getType() == PHPRegionTypes.PHP_USE) {
              String[] types = statementText1.toString().trim()
                  .substring(3).trim().split(","); //$NON-NLS-1$
              useTypes = new ArrayList<String>();
              for (String type : types) {
                useTypes.add(type.trim());
              }
              return true;
            } else {
              return false;
            }
          } else if (startTokenRegion.getType() == PHPRegionTypes.PHP_CURLY_CLOSE) {
            return false;
          }

          startTokenRegion = phpScriptRegion
              .getPhpToken(startTokenRegion.getStart() - 1);
        }

      } catch (BadLocationException e) {
      }
View Full Code Here

  public int getPrefixEnd() throws BadLocationException {
    ITextRegion phpToken = getPHPToken();
    if (phpToken.getType() == PHPRegionTypes.PHP_NS_SEPARATOR) {
      if (phpToken.getLength() == phpToken.getTextLength()) {
        IPhpScriptRegion phpScriptRegion = getPhpScriptRegion();
        ITextRegion nextRegion = phpScriptRegion.getPhpToken(phpToken
            .getEnd());
        return getRegionCollection().getStartOffset()
            + phpScriptRegion.getStart() + nextRegion.getTextEnd();
      }
    }
    return super.getPrefixEnd();
  }
View Full Code Here

  public int getPrefixEnd() throws BadLocationException {
    ITextRegion phpToken = getPHPToken();
    if (phpToken.getType() == PHPRegionTypes.PHP_OBJECT_OPERATOR
        || phpToken.getType() == PHPRegionTypes.PHP_PAAMAYIM_NEKUDOTAYIM) {
      IPhpScriptRegion phpScriptRegion = getPhpScriptRegion();
      ITextRegion nextRegion = phpScriptRegion.getPhpToken(phpToken
          .getEnd());

      if (phpToken.getTextLength() == phpToken.getLength()) {
        int addOffset = 0;
        if (nextRegion.getType() == PHPRegionTypes.PHP_TOKEN
            || nextRegion.getType() == PHPRegionTypes.PHP_SEMICOLON) {
          addOffset = phpToken.getEnd();
        } else {
          addOffset = nextRegion.getTextEnd();
        }
        return getRegionCollection().getStartOffset()
            + phpScriptRegion.getStart() + addOffset;
      }
    }
    return super.getPrefixEnd();
  }
View Full Code Here

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

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

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

      if (tRegion != null && tRegion instanceof IPhpScriptRegion) {
        IPhpScriptRegion scriptRegion = (IPhpScriptRegion) tRegion;
        int regionOffset = offset - regionStart;
        ITextRegion innerRegion = scriptRegion
            .getPhpToken(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

  }

  public int getPrefixEnd() throws BadLocationException {
    ITextRegion phpToken = getPHPToken();
    if (phpToken.getType() == PHPRegionTypes.PHP_NS_SEPARATOR) {
      IPhpScriptRegion phpScriptRegion = getPhpScriptRegion();
      ITextRegion nextRegion = phpScriptRegion.getPhpToken(phpToken
          .getEnd());
      return getRegionCollection().getStartOffset()
          + phpScriptRegion.getStart() + nextRegion.getTextEnd();
    }
    return super.getPrefixEnd();
  }
View Full Code Here

    }

    // This text region must be of type PhpScriptRegion:
    if (tRegion != null
        && tRegion.getType() == PHPRegionContext.PHP_CONTENT) {
      IPhpScriptRegion phpScriptRegion = (IPhpScriptRegion) tRegion;

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

        // Now, search backwards for the statement start (in this
        // PhpScriptRegion):
        ITextRegion startTokenRegion;
        if (documentOffset == startOffset) {
          startTokenRegion = phpScriptRegion.getPhpToken(0);
        } else {
          startTokenRegion = phpScriptRegion.getPhpToken(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
          /* || startTokenRegion.getType() == PHPRegionTypes.PHP_IF */) {
            // Calculate starting position of the statement (it
            // should go right after this startTokenRegion):
            startOffset += startTokenRegion.getEnd();
            break;
          }
          startTokenRegion = phpScriptRegion
              .getPhpToken(startTokenRegion.getStart() - 1);
        }

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

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

      if (phpScriptRegion instanceof IPhpScriptRegion) {
        IPhpScriptRegion scriptRegion = (IPhpScriptRegion) 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
            .getPhpToken(lineStart - phpContentStartOffset);
        // the current region we need to format
        ContextRegion currentRegion = (ContextRegion) scriptRegion
            .getPhpToken(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

          phpContentStartOffset += phpScriptRegion.getStart();
        }

        if (phpScriptRegion instanceof IPhpScriptRegion
            && lineStart <= phpScriptRegion.getEnd()) {
          IPhpScriptRegion scriptRegion = (IPhpScriptRegion) phpScriptRegion;
          ITextRegion[] tokens = null;
          try {
            tokens = scriptRegion.getPhpTokens(
                Math.min(lineStart - 1, scriptRegion.getEnd()),
                biggest - lineStart + 1);
          } catch (BadLocationException e) {
            // ignore it, scriptRegion.getEnd() is greater than last
            // phpToken
          }
View Full Code Here

TOP

Related Classes of org.eclipse.php.internal.core.documentModel.parser.regions.IPhpScriptRegion

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.