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


Java EditorImpl.getDocument方法代码示例

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


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

示例1: findDocument

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
private Document findDocument()
{
  Editor editor = ResourceToManifoldUtil.getActiveEditor( getProject() );
  if( editor instanceof EditorImpl )
  {
    EditorImpl editorImpl = (EditorImpl)editor;
    if( editorImpl.getVirtualFile().getPath().equals( _file.getVirtualFile().getPath() ) )
    {
      // get document from current editor
      return editorImpl.getDocument();
    }
  }

  // get document from file
  return _file.getViewProvider().getDocument();
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:17,代码来源:FakeTargetElement.java

示例2: EditorView

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
public EditorView(EditorImpl editor) {
  myFontRenderContext = createFontRenderContext();
  myEditor = editor;
  myDocument = editor.getDocument();
  
  myPainter = new EditorPainter(this);
  myMapper = new EditorCoordinateMapper(this);
  mySizeManager = new EditorSizeManager(this);
  myTextLayoutCache = new TextLayoutCache(this);
  myLogicalPositionCache = new LogicalPositionCache(this);
  myTabFragment = new TabFragment(this);
  
  Disposer.register(this, myLogicalPositionCache);
  Disposer.register(this, myTextLayoutCache);
  Disposer.register(this, mySizeManager);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EditorView.java

示例3: EditorView

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
public EditorView(EditorImpl editor) {
  myEditor = editor;
  myDocument = editor.getDocument();

  myPainter = new EditorPainter(this);
  myMapper = new EditorCoordinateMapper(this);
  mySizeManager = new EditorSizeManager(this);
  myTextLayoutCache = new TextLayoutCache(this);
  myLogicalPositionCache = new LogicalPositionCache(this);
  myTabFragment = new TabFragment(this);

  myEditor.getContentComponent().addHierarchyListener(this);
  myEditor.getScrollingModel().addVisibleAreaListener(this);

  Disposer.register(this, myLogicalPositionCache);
  Disposer.register(this, myTextLayoutCache);
  Disposer.register(this, mySizeManager);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:EditorView.java

示例4: getVisualLineInfo

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
private static VisualLineInfo getVisualLineInfo(@Nonnull EditorImpl editor, int offset, boolean beforeSoftWrap) {
  Document document = editor.getDocument();
  int textLength = document.getTextLength();
  if (offset <= 0 || textLength == 0) return new VisualLineInfo(0, false);
  offset = Math.min(offset, textLength);

  int startOffset = EditorUtil.getNotFoldedLineStartOffset(editor, offset);

  SoftWrapModelImpl softWrapModel = editor.getSoftWrapModel();
  int wrapIndex = softWrapModel.getSoftWrapIndex(offset);
  int prevSoftWrapIndex = wrapIndex < 0 ? (- wrapIndex - 2) : wrapIndex - (beforeSoftWrap ? 1 : 0);
  SoftWrap prevSoftWrap = prevSoftWrapIndex < 0 ? null : softWrapModel.getRegisteredSoftWraps().get(prevSoftWrapIndex);

  int visualLineStartOffset = prevSoftWrap == null ? startOffset : Math.max(startOffset, prevSoftWrap.getStart());
  return new VisualLineInfo(visualLineStartOffset, prevSoftWrap != null && prevSoftWrap.getStart() == visualLineStartOffset);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:IncrementalCacheUpdateEvent.java

示例5: actionPerformed

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent actionEvent) {
  project = actionEvent.getData(PlatformDataKeys.PROJECT);
  editor = (EditorImpl) actionEvent.getData(PlatformDataKeys.EDITOR);
  if (editor == null) {
    return;
  }
  document = editor.getDocument();

  final VirtualFile virtualFile = editor.getVirtualFile();
  if (virtualFile == null) {
    return;
  }

  jasmineFile = new JasmineFile(project, virtualFile);

  // Async callback to get the search results for it( and describe(
  jasmineFile.addResultsReadyListener(new ChangeListener() {
    @Override
    public void stateChanged(ChangeEvent changeEvent) {
      showDialog(virtualFile);
    }
  });
  jasmineFile.buildTreeNodeAsync();
}
 
开发者ID:andresdominguez,项目名称:ddescriber,代码行数:25,代码来源:JasmineDescribeReplaceAction.java

示例6: getWordAtCaretStart

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
private static int getWordAtCaretStart( Project project, String filePath )
{
  Editor[] editor = new Editor[1];
  editor[0] = getActiveEditor( project );
  if( !(editor[0] instanceof EditorImpl) )
  {
    return -1;
  }

  EditorImpl editorImpl = (EditorImpl)editor[0];
  if( !editorImpl.getVirtualFile().getPath().equals( filePath ) )
  {
    return -1;
  }

  CaretModel cm = editorImpl.getCaretModel();
  Document document = editorImpl.getDocument();
  int offset = cm.getOffset();
  if( offset == 0 )
  {
    return 0;
  }
  int lineNumber = cm.getLogicalPosition().line;
  int newOffset = offset - 1;
  int minOffset = lineNumber > 0 ? document.getLineEndOffset( lineNumber - 1 ) : 0;
  for( ; newOffset > minOffset; newOffset-- )
  {
    if( EditorActionUtil.isWordOrLexemeStart( editorImpl, newOffset, false ) )
    {
      break;
    }
  }

  return newOffset;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:36,代码来源:ResourceToManifoldUtil.java

示例7: init

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
private void init(EditorView view, int startOffset, int startLogicalLine, int currentOrPrevWrapIndex, int nextFoldingIndex,
                  @Nullable Runnable quickEvaluationListener) {
  myQuickEvaluationListener = quickEvaluationListener;
  myView = view;
  EditorImpl editor = view.getEditor();
  myDocument = editor.getDocument();
  FoldingModelEx foldingModel = editor.getFoldingModel();
  FoldRegion[] regions = foldingModel.fetchTopLevel();
  myRegions = regions == null ? FoldRegion.EMPTY_ARRAY : regions;
  SoftWrapModelImpl softWrapModel = editor.getSoftWrapModel();
  List<? extends SoftWrap> softWraps = softWrapModel.getRegisteredSoftWraps();
  SoftWrap currentOrPrevWrap = currentOrPrevWrapIndex < 0 || currentOrPrevWrapIndex >= softWraps.size() ? null :
                               softWraps.get(currentOrPrevWrapIndex);
  SoftWrap followingWrap = (currentOrPrevWrapIndex + 1) < 0 || (currentOrPrevWrapIndex + 1) >= softWraps.size() ? null :
                           softWraps.get(currentOrPrevWrapIndex + 1);

  myVisualLineStartOffset = mySegmentStartOffset = startOffset;

  myCurrentFoldRegionIndex = nextFoldingIndex;
  myCurrentEndLogicalLine = startLogicalLine;
  myCurrentX = myView.getInsets().left;
  if (mySegmentStartOffset == 0) {
    myCurrentX += myView.getPrefixTextWidthInPixels();
  }
  else if (currentOrPrevWrap != null && mySegmentStartOffset == currentOrPrevWrap.getStart()) {
    myCurrentX += currentOrPrevWrap.getIndentInPixels();
    myCurrentVisualColumn = currentOrPrevWrap.getIndentInColumns();
  }
  myNextWrapOffset = followingWrap == null ? Integer.MAX_VALUE : followingWrap.getStart();
  setInlaysAndFragmentIterator();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:32,代码来源:VisualLineFragmentsIterator.java

示例8: getWordAtCaretEnd

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
private static int getWordAtCaretEnd( Project project, String filePath )
{
  Editor[] editor = new Editor[1];
  editor[0] = getActiveEditor( project );
  if( !(editor[0] instanceof EditorImpl) )
  {
    return -1;
  }

  EditorImpl editorImpl = (EditorImpl)editor[0];
  if( !editorImpl.getVirtualFile().getPath().equals( filePath ) )
  {
    return -1;
  }

  CaretModel cm = editorImpl.getCaretModel();
  Document document = editorImpl.getDocument();
  int offset = cm.getOffset();

  if( offset >= document.getTextLength() - 1 || document.getLineCount() == 0 )
  {
    return offset;
  }

  int newOffset = offset + 1;

  int lineNumber = cm.getLogicalPosition().line;
  int maxOffset = document.getLineEndOffset( lineNumber );
  if( newOffset > maxOffset )
  {
    if( lineNumber + 1 >= document.getLineCount() )
    {
      return offset;
    }
    maxOffset = document.getLineEndOffset( lineNumber + 1 );
  }
  for( ; newOffset < maxOffset; newOffset++ )
  {
    if( EditorActionUtil.isWordOrLexemeEnd( editorImpl, newOffset, false ) )
    {
      break;
    }
  }

  return newOffset;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:47,代码来源:ResourceToManifoldUtil.java

示例9: VisualLineFragmentsIterator

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
private VisualLineFragmentsIterator(EditorView view, int offset, boolean beforeSoftWrap, @Nullable Runnable quickEvaluationListener) {
  myQuickEvaluationListener = quickEvaluationListener;
  myView = view;
  EditorImpl editor = view.getEditor();
  myDocument = editor.getDocument();
  FoldingModelEx foldingModel = editor.getFoldingModel();
  FoldRegion[] regions = foldingModel.fetchTopLevel();
  myRegions = regions == null ? FoldRegion.EMPTY_ARRAY : regions;
  int visualLineStartOffset = EditorUtil.getNotFoldedLineStartOffset(editor, offset);

  SoftWrapModelImpl softWrapModel = editor.getSoftWrapModel();
  List<? extends SoftWrap> softWraps = softWrapModel.getRegisteredSoftWraps();
  int currentOrPrevWrapIndex = softWrapModel.getSoftWrapIndex(offset);
  if (currentOrPrevWrapIndex < 0) {
    currentOrPrevWrapIndex = - currentOrPrevWrapIndex - 2;
  }
  else if (beforeSoftWrap) {
    currentOrPrevWrapIndex--;
  }
  SoftWrap currentOrPrevWrap = currentOrPrevWrapIndex < 0 || currentOrPrevWrapIndex >= softWraps.size() ? null :
                               softWraps.get(currentOrPrevWrapIndex);
  SoftWrap followingWrap = (currentOrPrevWrapIndex + 1) >= softWraps.size() ? null : softWraps.get(currentOrPrevWrapIndex + 1);

  if (currentOrPrevWrap != null && currentOrPrevWrap.getStart() > visualLineStartOffset) {
    visualLineStartOffset = currentOrPrevWrap.getStart();
  }
  
  myVisualLineStartOffset = mySegmentStartOffset = visualLineStartOffset;

  myCurrentFoldRegionIndex = foldingModel.getLastCollapsedRegionBefore(mySegmentStartOffset) + 1;
  myCurrentEndLogicalLine = myDocument.getLineNumber(mySegmentStartOffset);
  if (mySegmentStartOffset == 0) {
    myCurrentX = myView.getPrefixTextWidthInPixels();
  }
  else if (currentOrPrevWrap != null && mySegmentStartOffset == currentOrPrevWrap.getStart()) {
    myCurrentX = currentOrPrevWrap.getIndentInPixels();
    myCurrentVisualColumn = currentOrPrevWrap.getIndentInColumns();
  }
  myNextWrapOffset = followingWrap == null ? Integer.MAX_VALUE : followingWrap.getStart();
  setFragmentIterator();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:VisualLineFragmentsIterator.java


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