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

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


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

      if (interest.getType() == PHPRegionContext.PHP_CONTENT) {
        IPhpScriptRegion phpScript = (IPhpScriptRegion) interest;
        try {
          regionContext = phpScript
              .getPhpTokenType(offset
                  - container.getStartOffset()
                  - phpScript.getStart());
        } catch (BadLocationException e) {
          assert false;
          return null;
        }
      } else if (interest.getType() == PHPRegionContext.PHP_OPEN) {
View Full Code Here


      IStructuredDocument document) {

    // Find the first PHP script region:
    IStructuredDocumentRegion sdRegion = document
        .getFirstStructuredDocumentRegion();
    IPhpScriptRegion phpScriptRegion = null;
    ITextRegion textRegion = null;
    String docBlock = null;
    while (sdRegion != null && docBlock == null) {
      ITextRegion region = sdRegion.getFirstRegion();
      if (region.getType() == PHPRegionContext.PHP_OPEN) {
        // File's content starts with '<?PHP' tag
        region = sdRegion.getRegionAtCharacterOffset(region.getEnd()
            + sdRegion.getStart());
        if (region != null
            && region.getType() == PHPRegionContext.PHP_CONTENT) {
          phpScriptRegion = (IPhpScriptRegion) region;
          try {
            docBlock = CodeGeneration.getFileComment(data, null);
          } catch (CoreException e) {
            Logger.logException(
                "Generating default phpdoc comment", e); //$NON-NLS-1$
            docBlock = createDefaultComment(null);
          }
          break;
        }
      } else if (region.getType() == DOMRegionContext.XML_DECLARATION_OPEN) {
        // File's content starts with HTML code
        region = sdRegion.getRegionAtCharacterOffset(region.getEnd()
            + sdRegion.getStart());
        if (region != null) {
          phpScriptRegion = null;
          textRegion = (ITextRegion) region;
          docBlock = createPHPScopeFileDocBlock(data
              .getScriptProject());
          break;
        }
      }

      sdRegion = sdRegion.getNext();
    }

    if (phpScriptRegion != null || textRegion != null) {
      try {
        int offset = 0;
        if (phpScriptRegion == null && textRegion != null) {
          // File's content starts with HTML code
          offset = 0;
        } else if (phpScriptRegion != null) {
          // File's content starts with '<?php' tag
          textRegion = phpScriptRegion.getPhpToken(0);
          int lineDelimiterLength = document.getLineDelimiter(
              document.getLineOfOffset(textRegion.getStart()))
              .length();
          offset = textRegion.getStart() + sdRegion.getStartOffset()
              + phpScriptRegion.getStart() + lineDelimiterLength;
        } else {
          assert false;// we shouldn't get here ...
        }

        if (data instanceof AbstractSourceModule)
View Full Code Here

      ITextRegion textReg = structuredDocumentRegion
          .getRegionAtCharacterOffset(region.getOffset());
      if (textReg != null
          && textReg.getType() == PHPRegionContext.PHP_CONTENT
          && damageCoversWholeRegion(region, textReg, damage)) {
        IPhpScriptRegion phpScriptRegion = (IPhpScriptRegion) textReg;
        if (!phpScriptRegion.isFullReparsed()) {
          Region r = new Region(
              phpScriptRegion.getUpdatedTokensStart()
                  + region.getOffset(),
              phpScriptRegion.getUpdatedTokensLength());
          return new TextPresentation((IRegion) r, 1000);
        }
      }
    }
    return null;
View Full Code Here

                }

                // We should always hit the PhpScriptRegion:
                if (tRegion != null
                    && tRegion.getType() == PHPRegionContext.PHP_CONTENT) {
                  IPhpScriptRegion phpScriptRegion = (IPhpScriptRegion) tRegion;
                  tRegion = phpScriptRegion
                      .getPhpToken(caretPosition
                          - container
                              .getStartOffset()
                          - phpScriptRegion
                              .getStart());

                  // Handle double-click on PHPDoc tags:
                  if (tRegion.getType() == PHPRegionTypes.PHP_VARIABLE
                      || tRegion.getType() == PHPRegionTypes.PHP_THIS
                      || PHPPartitionTypes
                          .isPHPDocTagState(tRegion
                              .getType())) {
                    structuredTextViewer.setSelectedRange(
                        container.getStartOffset()
                            + phpScriptRegion
                                .getStart()
                            + tRegion.getStart(),
                        tRegion.getTextLength());
                    return; // Stop processing
                  }
View Full Code Here

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

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

          while (tRegion != null) {
            String regionType = tRegion.getType();
            if (regionType == PHPRegionTypes.PHP_TOKEN) {
              char token = document.getChar(regionStart
                  + tRegion.getStart());
              if (token == ROUND_OPEN || token == SQUARE_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) {
              return MATCHING_BRACKET_NOT_NEEDED;
            }
            if (tRegion.getStart() > 0) {
              tRegion = scriptRegion.getPhpToken(tRegion
                  .getStart() - 1);
            } else {
              break;
            }
          }
View Full Code Here

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

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

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

        IStructuredDocumentRegion sdRegion = ((BasicStructuredDocument) fDocument)
            .getRegionAtCharacterOffset(position);
        ITextRegion textRegion = sdRegion
            .getRegionAtCharacterOffset(position);
        if (textRegion instanceof IPhpScriptRegion) {
          IPhpScriptRegion phpScriptRegion = (IPhpScriptRegion) textRegion;
          textRegion = phpScriptRegion.getPhpToken(position
              - sdRegion.getStartOffset()
              - phpScriptRegion.getStart());
          // handle comments
          if (PHPPartitionTypes.isPHPCommentState(textRegion
              .getType())) {
            return new TypedRegion(position, 0,
                PHPPartitionTypes.PHP_COMMENT);
View Full Code Here

        IStructuredDocumentRegion sdRegion = ((BasicStructuredDocument) fDocument)
            .getRegionAtCharacterOffset(position);
        ITextRegion textRegion = sdRegion
            .getRegionAtCharacterOffset(position);
        if (textRegion instanceof IPhpScriptRegion) {
          IPhpScriptRegion phpScriptRegion = (IPhpScriptRegion) textRegion;
          textRegion = phpScriptRegion.getPhpToken(position
              - sdRegion.getStartOffset()
              - phpScriptRegion.getStart());
          return textRegion;
        }
      }

      return null;
View Full Code Here

              textRegion = container
                  .getRegionAtCharacterOffset(offset);
            }

            if (textRegion.getType() == PHPRegionContext.PHP_CONTENT) {
              IPhpScriptRegion phpScriptRegion = (IPhpScriptRegion) textRegion;
              textRegion = phpScriptRegion.getPhpToken(offset
                  - container.getStartOffset()
                  - phpScriptRegion.getStart());
              String type = textRegion.getType();
              if (PHPPartitionTypes
                  .isPHPMultiLineCommentState(type)
                  || PHPPartitionTypes.isPHPDocState(type)
                  || PHPPartitionTypes
View Full Code Here

              textRegion = container
                  .getRegionAtCharacterOffset(offset);
            }

            if (textRegion.getType() == PHPRegionContext.PHP_CONTENT) {
              IPhpScriptRegion phpScriptRegion = (IPhpScriptRegion) textRegion;
              textRegion = phpScriptRegion.getPhpToken(offset
                  - container.getStartOffset()
                  - phpScriptRegion.getStart());
              String type = textRegion.getType();
              if (PHPPartitionTypes
                  .isPHPMultiLineCommentState(type)
                  || PHPPartitionTypes.isPHPDocState(type)
                  || PHPPartitionTypes
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.