本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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);
}
示例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);
}
}