Package melnorme.lang.ide.ui.text

Examples of melnorme.lang.ide.ui.text.BlockHeuristicsScannner


  protected BlockHeuristicsScannner createBlockHeuristicsScanner(IDocument doc) {
    BlockTokenRule[] blockTokens = array(new BlockTokenRule('{', '}'));
    if(parenthesesAsBlocks) {
      blockTokens = ArrayUtil.concat(blockTokens, new BlockTokenRule('(', ')'));
    }
    return new BlockHeuristicsScannner(doc, partitioning, contentType, blockTokens);
  }
View Full Code Here


 
  protected BlockHeuristicsScannner createBlockHeuristicsScanner(IDocument doc) {
    // Default implementation
    String partitioning = IDocumentExtension3.DEFAULT_PARTITIONING;
    String contentType = IDocument.DEFAULT_CONTENT_TYPE;
    return new BlockHeuristicsScannner(doc, partitioning, contentType, new BlockTokenRule('{', '}'));
  }
View Full Code Here

  public static int getRegionEnd(IRegion region) {
    return region.getOffset() + region.getLength();
  }
 
  protected void smartIndentAfterNewLine(IDocument doc, DocumentCommand cmd) throws BadLocationException {
    BlockHeuristicsScannner bhscanner = createBlockHeuristicsScanner(doc);
    // Find block balances of preceding text (line start to edit cursor)
    LineIndentResult nli = determineIndent(doc, bhscanner, doc.getLineOfOffset(cmd.offset), cmd.offset);
    cmd.text += nli.nextLineIndent;
    BlockBalanceResult blockInfo = nli.blockInfo;
   
    if(blockInfo.unbalancedOpens > 0) {
      IRegion lineRegion = doc.getLineInformationOfOffset(cmd.offset);
      int lineEnd = getRegionEnd(lineRegion);
     
      int postWsEndPos = AutoEditUtils.findEndOfWhiteSpace(doc, cmd.offset, lineEnd);
      boolean hasPendingTextAfterEdit = postWsEndPos != lineEnd;
      if (fCloseBlocks && !hasPendingTextAfterEdit){
        if(bhscanner.shouldCloseBlock(blockInfo.rightmostUnbalancedBlockOpenOffset)) {
          //close block
          cmd.caretOffset = cmd.offset + cmd.text.length();
          cmd.shiftsCaret = false;
          String delimiter = TextUtilities.getDefaultLineDelimiter(doc);
          char openChar = doc.getChar(blockInfo.rightmostUnbalancedBlockOpenOffset);
          char closeChar = bhscanner.getClosingPeer(openChar);
          cmd.text += delimiter + addIndent(nli.editLineIndent, blockInfo.unbalancedOpens - 1) + closeChar;
        }
      }
      return;
    }
View Full Code Here

  protected int findEndOfWhiteSpace(IDocument doc, IRegion region) throws BadLocationException {
    return AutoEditUtils.findEndOfWhiteSpace(doc, region.getOffset(), getRegionEnd(region));
  }
 
  protected String determineExpectedIndent(IDocument doc, int line) throws BadLocationException {
    BlockHeuristicsScannner bhscanner = createBlockHeuristicsScanner(doc);
    LineIndentResult nli = determineIndent(doc, bhscanner, line);
    String expectedIndentStr = nli.nextLineIndent;
    return expectedIndentStr;
  }
View Full Code Here

 
  public static BlockHeuristicsScannner createBlockHeuristicScannerWithSamplePartitioning(IDocument document) {
    String partitioning = SamplePartitionScanner.LANG_PARTITIONING;
    String contentType = IDocument.DEFAULT_CONTENT_TYPE;
    BlockTokenRule[] blockTokens = BlockHeuristicsScannnerTest.SAMPLE_BLOCK_TOKENS;
    return new BlockHeuristicsScannner(document, partitioning, contentType, blockTokens);
  }
View Full Code Here

TOP

Related Classes of melnorme.lang.ide.ui.text.BlockHeuristicsScannner

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.