当前位置: 首页>>代码示例>>Java>>正文


Java DocumentEx.getLineStartOffset方法代码示例

本文整理汇总了Java中com.intellij.openapi.editor.ex.DocumentEx.getLineStartOffset方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentEx.getLineStartOffset方法的具体用法?Java DocumentEx.getLineStartOffset怎么用?Java DocumentEx.getLineStartOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.editor.ex.DocumentEx的用法示例。


在下文中一共展示了DocumentEx.getLineStartOffset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addFolding

import com.intellij.openapi.editor.ex.DocumentEx; //导入方法依赖的package包/类
@Nullable
private static FoldRegion addFolding(@NotNull EditorEx editor, int start, int end, boolean expanded) {
  DocumentEx document = editor.getDocument();
  final int startOffset = document.getLineStartOffset(start);
  final int endOffset = document.getLineEndOffset(end - 1);

  FoldRegion value = editor.getFoldingModel().addFoldRegion(startOffset, endOffset, PLACEHOLDER);
  if (value != null) value.setExpanded(expanded);
  return value;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:FoldingModelSupport.java

示例2: translateViaDiff

import com.intellij.openapi.editor.ex.DocumentEx; //导入方法依赖的package包/类
private boolean translateViaDiff(final DocumentEventImpl event) {
  try {
    myStartLine = event.translateLineViaDiffStrict(myStartLine);
    DocumentEx document = getDocument();
    if (myStartLine < 0 || myStartLine >= document.getLineCount()) {
      invalidate(event);
    }
    else {
      int start = document.getLineStartOffset(myStartLine) + myStartColumn;
      if (start >= document.getTextLength()) return false;
      setIntervalStart(start);
    }

    myEndLine = event.translateLineViaDiffStrict(myEndLine);
    if (myEndLine < 0 || myEndLine >= document.getLineCount()) {
      invalidate(event);
    }
    else {
      int end = document.getLineStartOffset(myEndLine) + myEndColumn;
      if (end > document.getTextLength()) return false;
      setIntervalEnd(end);
    }
    return true;
  }
  catch (FilesTooBigForDiffException e) {
    return false;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:PersistentRangeMarker.java

示例3: addFolding

import com.intellij.openapi.editor.ex.DocumentEx; //导入方法依赖的package包/类
@javax.annotation.Nullable
private static FoldRegion addFolding(@Nonnull EditorEx editor, int start, int end, boolean expanded) {
  DocumentEx document = editor.getDocument();
  final int startOffset = document.getLineStartOffset(start);
  final int endOffset = document.getLineEndOffset(end - 1);

  FoldRegion value = editor.getFoldingModel().addFoldRegion(startOffset, endOffset, PLACEHOLDER);
  if (value != null) value.setExpanded(expanded);
  return value;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:11,代码来源:FoldingModelSupport.java

示例4: getLogicalLineStartOffset

import com.intellij.openapi.editor.ex.DocumentEx; //导入方法依赖的package包/类
private int getLogicalLineStartOffset(int logicalLine) {
  DocumentEx document = myEditor.getDocument();
  return logicalLine >= document.getLineCount() ? document.getTextLength() : document.getLineStartOffset(logicalLine);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:CachingSoftWrapDataMapper.java

示例5: executeWriteAction

import com.intellij.openapi.editor.ex.DocumentEx; //导入方法依赖的package包/类
@Override
public void executeWriteAction(final Editor editor, final DataContext dataContext) {
  if (!(editor.getDocument() instanceof DocumentEx)) {
    myOriginalHandler.execute(editor, dataContext);
    return;
  }
  final DocumentEx doc = (DocumentEx)editor.getDocument();
  final Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(editor.getContentComponent()));
  if (project == null) {
    return;
  }

  LogicalPosition caretPosition = editor.getCaretModel().getLogicalPosition();

  final PsiDocumentManager docManager = PsiDocumentManager.getInstance(project);
  PsiFile psiFile = docManager.getPsiFile(doc);

  if (psiFile == null) {
    myOriginalHandler.execute(editor, dataContext);
    return;
  }

  int startLine = caretPosition.line;
  int endLine = startLine + 1;
  if (editor.getSelectionModel().hasSelection()) {
    startLine = doc.getLineNumber(editor.getSelectionModel().getSelectionStart());
    endLine = doc.getLineNumber(editor.getSelectionModel().getSelectionEnd());
    if (doc.getLineStartOffset(endLine) == editor.getSelectionModel().getSelectionEnd()) endLine--;
  }

  final int startReformatOffset = CharArrayUtil.shiftBackward(doc.getCharsSequence(), doc.getLineEndOffset(startLine), " \t");
  CodeEditUtil.setNodeReformatStrategy(new NotNullFunction<ASTNode, Boolean>() {
    @NotNull
    @Override
    public Boolean fun(ASTNode node) {
      return node.getTextRange().getStartOffset() >= startReformatOffset;
    }
  });
  try {
    doJob(editor, doc, project, docManager, psiFile, startLine, endLine);
  }
  finally {
    CodeEditUtil.setNodeReformatStrategy(null);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:46,代码来源:JoinLinesHandler.java


注:本文中的com.intellij.openapi.editor.ex.DocumentEx.getLineStartOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。