Examples of IPhpScriptRegion


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

      ITextRegionContainer container = (ITextRegionContainer) tRegion;
      tRegion = container.getRegionAtCharacterOffset(offset);
      regionStart += tRegion.getStart();
    }
    if (tRegion instanceof IPhpScriptRegion) {
      IPhpScriptRegion scriptRegion = (IPhpScriptRegion) tRegion;
      tRegion = scriptRegion.getPhpToken(offset - regionStart);
      regionStart += tRegion.getStart();
    }
    return regionStart;
  }
View Full Code Here

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

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

      if (tRegion instanceof IPhpScriptRegion) {
        IPhpScriptRegion scriptRegion = (IPhpScriptRegion) tRegion;
        tRegion = scriptRegion.getPhpToken(offset - regionStart);

        if (tRegion == null
            || tRegion.getType() != PHPRegionTypes.PHP_CONSTANT_ENCAPSED_STRING) {
          return;
        }
View Full Code Here

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

      if (region instanceof ITextRegionContainer) {
        reparseRegion(doc, ((ITextRegionContainer) region).getRegions()
            .iterator(), offset + region.getStart());
      }
      if (region instanceof IPhpScriptRegion) {
        final IPhpScriptRegion phpRegion = (IPhpScriptRegion) region;
        try {
          phpRegion.completeReparse(doc, offset + region.getStart(),
              region.getLength());
        } catch (Error e) {
          // catch Error from PhpLexer.zzScanError
          // without doing this,the editor will behavior unnormal
          PHPUiPlugin.log(e);
View Full Code Here

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

    ITextRegionCollection container = flatNode;
    if (region instanceof ITextRegionContainer) {
      container = (ITextRegionContainer) region;
      region = container.getRegionAtCharacterOffset(offset);
    }
    IPhpScriptRegion phpScriptRegion = null;
    if (region.getType() == PHPRegionContext.PHP_CONTENT) {
      phpScriptRegion = (IPhpScriptRegion) region;
      try {
        region = phpScriptRegion.getPhpToken(offset
            - container.getStartOffset() - region.getStart());
      } catch (BadLocationException e) {
        region = null;
      }

      if (region != null) {
        int varOffset = 0;
        int varLength = 0;

        String regionType = region.getType();
        if (regionType == PHPRegionTypes.PHP_VARIABLE) {
          varOffset = hoverRegion.getOffset();
          varLength = hoverRegion.getLength();
          try {
            ITextRegion prevPhpToken = phpScriptRegion
                .getPhpToken(region.getStart() - 1);
            if (prevPhpToken != null
                && prevPhpToken.getType() == PHPRegionTypes.PHP_PAAMAYIM_NEKUDOTAYIM) {
              prevPhpToken = phpScriptRegion
                  .getPhpToken(prevPhpToken.getStart() - 1);
              varLength += varOffset - prevPhpToken.getStart();
              varOffset = prevPhpToken.getStart();
            }
          } catch (BadLocationException e) {
            Logger.logException("Error retrieving the value\n", e); //$NON-NLS-1$
          }
        } else if (regionType == PHPRegionTypes.PHP_STRING) {
          try {
            ITextRegion nextRegion = phpScriptRegion
                .getPhpToken(region.getEnd());
            ITextRegion prevRegion = phpScriptRegion
                .getPhpToken(region.getStart() - 1);
            if (prevRegion.getType() == PHPRegionTypes.PHP_OBJECT_OPERATOR) {
              prevRegion = phpScriptRegion.getPhpToken(prevRegion
                  .getStart() - 1);
              if (prevRegion.getType() == PHPRegionTypes.PHP_VARIABLE) {
                String nextTokenString = textViewer
                    .getDocument()
                    .get(phpScriptRegion.getStart()
                        + nextRegion.getStart(),
                        nextRegion.getLength());
                if (!"(".equals(nextTokenString)) { //$NON-NLS-1$
                  varOffset = phpScriptRegion.getStart()
                      + prevRegion.getStart();
                  varLength = region.getEnd()
                      - prevRegion.getStart();
                }
              }
View Full Code Here

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

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

    if (tRegion instanceof IPhpScriptRegion) {
      IPhpScriptRegion scriptRegion = (IPhpScriptRegion) tRegion;
      tRegion = scriptRegion.getPhpToken(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 (!PHPPartitionTypes.isPHPCommentState(token)
            && token != PHPRegionTypes.WHITESPACE) {
          // not comment nor white space
          return tRegion;
        }
        if (tRegion.getStart() >= 1) {
          tRegion = scriptRegion.getPhpToken(tRegion.getStart() - 1);
        } else {
          tRegion = null;
        }
      } while (tRegion != null
          && tRegion.getStart() + regionStart > lineStartOffset);
View Full Code Here

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

            container = (ITextRegionContainer) tRegion;
            tRegion = container.getRegionAtCharacterOffset(offset);
          }
          if (tRegion != null
              && tRegion.getType() == PHPRegionContext.PHP_CONTENT) {
            IPhpScriptRegion phpScriptRegion = (IPhpScriptRegion) tRegion;
            try {
              tRegion = phpScriptRegion.getPhpToken(offset
                  - container.getStartOffset()
                  - phpScriptRegion.getStart());
            } catch (BadLocationException e) {
            }
            if (tRegion != null) {
              // Determine element name:
              int elementStart = container.getStartOffset()
                  + phpScriptRegion.getStart()
                  + tRegion.getStart();
              TextSequence statement = PHPTextSequenceUtilities
                  .getStatement(
                      elementStart + tRegion.getLength(),
                      sRegion, true);
View Full Code Here

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

          tRegion = container.getRegionAtCharacterOffset(offset);
        }

        if (tRegion != null
            && tRegion.getType() == PHPRegionContext.PHP_CONTENT) {
          IPhpScriptRegion phpScriptRegion = (IPhpScriptRegion) tRegion;
          tRegion = phpScriptRegion.getPhpToken(offset
              - container.getStartOffset()
              - phpScriptRegion.getStart());
          if (tRegion == null) {
            return EMPTY;
          }
          // Determine element name:
          int elementStart = container.getStartOffset()
              + phpScriptRegion.getStart() + tRegion.getStart();
          TextSequence statement = PHPTextSequenceUtilities
              .getStatement(elementStart + tRegion.getLength(),
                  sRegion, true);
          if (statement == null) {
            return EMPTY;
          }
          int endPosition = PHPTextSequenceUtilities
              .readBackwardSpaces(statement, statement.length());
          int startPosition = PHPTextSequenceUtilities
              .readIdentifierStartIndex(phpVersion, statement,
                  endPosition, true);
          String elementName = statement.subSequence(startPosition,
              endPosition).toString();

          // Determine previous word:
          int prevWordEnd = PHPTextSequenceUtilities
              .readBackwardSpaces(statement, startPosition);
          int prevWordStart = PHPTextSequenceUtilities
              .readIdentifierStartIndex(phpVersion, statement,
                  prevWordEnd, false);
          String prevWord = statement.subSequence(prevWordStart,
              prevWordEnd).toString();

          // Determine next word:
          ITextRegion nextRegion = tRegion;
          do {
            nextRegion = phpScriptRegion.getPhpToken(nextRegion
                .getEnd());
            if (!PHPPartitionTypes.isPHPCommentState(nextRegion
                .getType())
                && nextRegion.getType() != PHPRegionTypes.WHITESPACE) {
              break;
            }
          } while (nextRegion.getEnd() < phpScriptRegion.getLength());

          String nextWord = sDoc.get(
              container.getStartOffset()
                  + phpScriptRegion.getStart()
                  + nextRegion.getStart(),
              nextRegion.getTextLength());

          if (elementName.length() > 0) {
            IType containerType = PHPModelUtils.getCurrentType(
View Full Code Here

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

          .getOffset());
      regionStart += tRegion.getStart();
    }

    if (tRegion instanceof IPhpScriptRegion) {
      IPhpScriptRegion scriptRegion = (IPhpScriptRegion) tRegion;
      tRegion = scriptRegion.getPhpToken(previousLine.getOffset()
          - regionStart);
      if (tRegion.getStart() + regionStart < previousLine.getOffset()) {
        tRegion = scriptRegion.getPhpToken(tRegion.getEnd());
      }
    }

    // Check if the previous line is the start of the comment.
    if (tRegion.getType() == PHPRegionTypes.PHP_COMMENT_START
View Full Code Here

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

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

    if (tRegion instanceof IPhpScriptRegion) {
      IPhpScriptRegion scriptRegion = (IPhpScriptRegion) tRegion;
      tRegion = scriptRegion.getPhpToken(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) {
            found = true;
            addIndentation = true;
          }
        } else if (token == PHPRegionTypes.PHP_CURLY_CLOSE) {
          curlyCount++;
        } else if ((token == PHPRegionTypes.PHP_CASE)
            || (token == PHPRegionTypes.PHP_DEFAULT)) {
          if (curlyCount == 0)
            found = true;
        }
        if (found) {
          indentationBase = document
              .getLineInformationOfOffset(tRegion.getStart()
                  + regionStart);
          break;
        }
        if (tRegion.getStart() > 0) {
          tRegion = scriptRegion.getPhpToken(tRegion.getStart() - 1);
        } else {
          break;
        }
      }
    }
View Full Code Here

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

   */
  protected IPhpScriptRegion determinePhpRegion(IStructuredDocument document,
      ITextRegionCollection regionCollection, int offset) {
    ITextRegion textRegion = determineTextRegion(document,
        regionCollection, offset);
    IPhpScriptRegion phpScriptRegion = null;

    if (textRegion != null) {
      if (textRegion.getType() == PHPRegionContext.PHP_OPEN) {
        return null;
      } else if (textRegion.getType() == PHPRegionContext.PHP_CLOSE) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.