Examples of IStructuredDocument


Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

    // use BlockMaker instead of CMElementDeclaration
    // because <style> and <script> in XHTML is not CDATA content type
    IDOMModel model = getModel();
    if (model == null)
      return false; // error
    IStructuredDocument structuredDocument = model.getStructuredDocument();
    if (structuredDocument == null || fTagName == null)
      return false; // eror
    RegionParser parser = structuredDocument.getParser();
    if (parser == null || !(parser instanceof XMLSourceParser))
      return false;
    return (((XMLSourceParser) parser).getBlockMarker(new String(this.fTagName)) != null);
    /*
     * CMElementDeclaration decl = getDeclaration(); if (decl == null)
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

   */

  public String getText() {
    String result = null;
    try {
      IStructuredDocument parentDocument = _getParentDocument();
      result = parentDocument.get(start, length);
    } catch (BadLocationException e) {
      Logger.logException("program error: unreachable exception", e); //$NON-NLS-1$
    }
    return result;
  }
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

  static private void lock(IStructuredDocumentRegion node, boolean canInsertBefore, boolean canInsertAfter) {
    if (node == null) {
      return;
    }
    IStructuredDocument doc = node.getParentDocument();
    if (doc == null) {
      return;
    }
    if (doc instanceof BasicStructuredDocument) {
      ((BasicStructuredDocument)doc).makeReadOnly(node.getStart(), node.getLength(), canInsertBefore, canInsertAfter);
    } else {
      doc.makeReadOnly(node.getStart(), node.getLength());
    }
  }
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

  static private void unlock(IStructuredDocumentRegion node) {
    if (node == null) {
      return;
    }
    IStructuredDocument doc = node.getParentDocument();
    if (doc == null) {
      return;
    }
    doc.clearReadOnly(node.getStart(), node.getLength());
  }
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

    // start node
    flatNode = node.getStartStructuredDocumentRegion();
    if (flatNode != null) {
      Span span = getDataSpan(node);
      if (0 <= span.length) {
        IStructuredDocument structuredDocument = flatNode.getParentDocument();
        int offset, length;
        offset = flatNode.getStart();
        length = span.offset;
        lock(structuredDocument, offset, length, false, false);
        offset = offset + span.offset + span.length;
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

      } else {
        Span span = getDataSpan(node);
        if (span.length <= 0) {
          unlock(flatNode);
        } else {
          IStructuredDocument structuredDocument = flatNode.getParentDocument();
          int offset, length;
          offset = flatNode.getStart();
          length = span.offset - offset;
          unlock(structuredDocument, offset, length);
          offset = span.offset + span.length;
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

  public TextEdit format(IStructuredModel model, int start, int length, XMLFormattingPreferences preferences) {
    setFormattingPreferences(preferences);

    TextEdit edit = new MultiTextEdit();
    IStructuredDocument document = model.getStructuredDocument();
    // get initial document region
    IStructuredDocumentRegion currentRegion = document.getRegionAtCharacterOffset(start);
    if (currentRegion != null) {
      int startOffset = currentRegion.getStartOffset();

      // get initial dom node
      IndexedRegion currentIndexedRegion = model.getIndexedRegion(startOffset);
      if (currentIndexedRegion instanceof IDOMNode) {
        // set up domRegion which will contain current region to be
        // formatted
        IDOMNode currentDOMNode = (IDOMNode) currentIndexedRegion;
        DOMRegion domRegion = new DOMRegion();
        domRegion.documentRegion = currentRegion;
        domRegion.domNode = currentDOMNode;
       
        XMLFormattingConstraints parentConstraints = getRegionConstraints(currentDOMNode);
       
        /* if the whitespace strategy is declared as default, get it from the preferences */
        if(XMLFormattingConstraints.DEFAULT.equals(parentConstraints.getWhitespaceStrategy()))
          parentConstraints.setWhitespaceStrategy(preferences.getElementWhitespaceStrategy());
       
        // TODO: initialize indentLevel
        // initialize available line width
        int lineWidth = getFormattingPreferences().getMaxLineWidth();
        try {
          IRegion lineInfo = document.getLineInformationOfOffset(startOffset);
          lineWidth = lineWidth - (startOffset - lineInfo.getOffset());
        }
        catch (BadLocationException e) {
          Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
        }
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

      if (XMLFormattingConstraints.INDENT.equals(indentStrategy) || XMLFormattingConstraints.NEW_LINE.equals(indentStrategy)) {
        int availableLineWidth = indentIfPossible(textEdit, constraints, currentDocumentRegion, previousDocumentRegion, whitespaceStrategy, indentStrategy, false);
        constraints.setAvailableLineWidth(availableLineWidth);
      }
      else if ( XMLFormattingConstraints.INLINE.equals(indentStrategy)){
        IStructuredDocument doc = currentDocumentRegion.getParentDocument();
        int currentLine = doc.getLineOfOffset(currentDocumentRegion.getStartOffset());
        int prevLine = doc.getLineOfOffset(previousDocumentRegion.getStartOffset());
        if ( currentLine != prevLine){
          int availableLineWidth = indentIfPossible(textEdit, constraints, currentDocumentRegion, previousDocumentRegion, whitespaceStrategy, indentStrategy, false);
          constraints.setAvailableLineWidth(availableLineWidth);
        }
      }
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

    }
    return lineWidth;
  }

  private String getLineDelimiter(IStructuredDocumentRegion currentRegion) {
    IStructuredDocument doc = currentRegion.getParentDocument();
    int line = doc.getLineOfOffset(currentRegion.getStartOffset());
    String lineDelimiter = doc.getLineDelimiter();
    try {
      if (line > 0) {
        lineDelimiter = doc.getLineDelimiter(line - 1);
      }
    }
    catch (BadLocationException e) {
      // log for now, unless we find reason not to
      Logger.log(Logger.INFO, e.getMessage());
    }
    // BUG115716: if cannot get line delimiter from current line, just
    // use default line delimiter
    if (lineDelimiter == null)
      lineDelimiter = doc.getLineDelimiter();
    return lineDelimiter;
  }
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

   *
   */
  public void newModel(NewDocumentEvent structuredDocumentEvent) {
    if (structuredDocumentEvent == null)
      return;
    IStructuredDocument structuredDocument = structuredDocumentEvent.getStructuredDocument();
    if (structuredDocument == null)
      return;
    // this should not happen, but for the case
    if (fStructuredDocument != null && fStructuredDocument != structuredDocument)
      setStructuredDocument(structuredDocument);
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.