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


Java EditorImpl类代码示例

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


EditorImpl类属于com.intellij.openapi.editor.impl包,在下文中一共展示了EditorImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: configureFromFileTextWithoutPSI

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
@NotNull
protected static Editor configureFromFileTextWithoutPSI(@NonNls @NotNull final String fileText) {
  return new WriteCommandAction<Editor>(null) {
    @Override
    protected void run(@NotNull Result<Editor> result) throws Throwable {
      final Document fakeDocument = EditorFactory.getInstance().createDocument(fileText);
      EditorTestUtil.CaretAndSelectionState caretsState = EditorTestUtil.extractCaretAndSelectionMarkers(fakeDocument);

      String newFileText = fakeDocument.getText();
      Document document = EditorFactory.getInstance().createDocument(newFileText);
      final Editor editor = EditorFactory.getInstance().createEditor(document);
      ((EditorImpl)editor).setCaretActive();

      EditorTestUtil.setCaretsAndSelection(editor, caretsState);
      result.setResult(editor);
    }
  }.execute().getResultObject();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:LightPlatformCodeInsightTestCase.java

示例3: moveCaretRelativelyAndScroll

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
public static void moveCaretRelativelyAndScroll(@NotNull Editor editor,
                                                int columnShift,
                                                int lineShift,
                                                boolean withSelection) {
  Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
  VisualPosition pos = editor.getCaretModel().getVisualPosition();
  Point caretLocation = editor.visualPositionToXY(pos);
  int caretVShift = caretLocation.y - visibleArea.y;

  editor.getCaretModel().moveCaretRelatively(columnShift, lineShift, withSelection, false, false);

  VisualPosition caretPos = editor.getCaretModel().getVisualPosition();
  Point caretLocation2 = editor.visualPositionToXY(caretPos);
  final boolean scrollToCaret = !(editor instanceof EditorImpl) || ((EditorImpl)editor).isScrollToCaret();
  if (scrollToCaret) {
    editor.getScrollingModel().scrollVertically(caretLocation2.y - caretVShift);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:EditorActionUtil.java

示例4: execute

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
@Override
public void execute(Editor editor, DataContext dataContext) {
  editor.getCaretModel().removeSecondaryCarets();
  int offset = editor.getDocument().getTextLength();
  if (editor instanceof EditorImpl && ((EditorImpl)editor).myUseNewRendering) {
    editor.getCaretModel().moveToLogicalPosition(editor.offsetToLogicalPosition(offset).leanForward(true));
  }
  else {
    editor.getCaretModel().moveToOffset(offset);
  }
  editor.getSelectionModel().removeSelection();

  ScrollingModel scrollingModel = editor.getScrollingModel();
  scrollingModel.disableAnimation();
  scrollingModel.scrollToCaret(ScrollType.CENTER);
  scrollingModel.enableAnimation();

  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project != null) {
    IdeDocumentHistory instance = IdeDocumentHistory.getInstance(project);
    if (instance != null) {
      instance.includeCurrentCommandAsNavigation();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:TextEndAction.java

示例5: visualLineStartOffset

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
private int visualLineStartOffset(int offset, boolean leanForward) {
  EditorImpl editor = myView.getEditor();
  int result = EditorUtil.getNotFoldedLineStartOffset(editor, offset);

  SoftWrapModelImpl softWrapModel = editor.getSoftWrapModel();
  List<? extends SoftWrap> softWraps = softWrapModel.getRegisteredSoftWraps();
  int currentOrPrevWrapIndex = softWrapModel.getSoftWrapIndex(offset);
  SoftWrap currentOrPrevWrap;
  if (currentOrPrevWrapIndex < 0) {
    currentOrPrevWrapIndex = - currentOrPrevWrapIndex - 2;
    currentOrPrevWrap = currentOrPrevWrapIndex < 0 || currentOrPrevWrapIndex >= softWraps.size() ? null :
                        softWraps.get(currentOrPrevWrapIndex);
  }
  else {
    currentOrPrevWrap = leanForward ? softWraps.get(currentOrPrevWrapIndex) : null;
  }
  if (currentOrPrevWrap != null && currentOrPrevWrap.getStart() > result) {
    result = currentOrPrevWrap.getStart();
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:EditorCoordinateMapper.java

示例6: 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

示例7: IncrementalCacheUpdateEvent

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
private IncrementalCacheUpdateEvent(@NotNull Document document, int startOffset, int oldEndOffset, int newEndOffset, 
                                    @NotNull CachingSoftWrapDataMapper mapper, @NotNull EditorImpl editor) {
  myStartOffset = editor.myUseNewRendering ? editor.visualLineStartOffset(editor.offsetToVisualLine(startOffset) - 1) : 
                  mapper.getPreviousVisualLineStartOffset(startOffset);
  myMandatoryEndOffset = newEndOffset;
  myLengthDiff = newEndOffset - oldEndOffset;
  myStartLogicalPosition = editor.myUseNewRendering ? editor.offsetToLogicalPosition(myStartOffset) : 
                           mapper.offsetToLogicalPosition(myStartOffset);
  if (editor.myUseNewRendering) {
    myStartVisualPosition = editor.logicalToVisualPosition(myStartLogicalPosition);
  }
  else {
    LOG.assertTrue(myStartLogicalPosition.visualPositionAware);
    myStartVisualPosition = myStartLogicalPosition.toVisualPosition();
  }
  myOldEndLogicalLine = document.getLineNumber(oldEndOffset);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:IncrementalCacheUpdateEvent.java

示例8: isCaretAfterSoftWrap

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
/**
 * Every soft wrap implies that multiple visual positions correspond to the same document offset. We can classify
 * such positions by the following criteria:
 * <pre>
 * <ul>
 *   <li>positions from visual line with soft wrap start;</li>
 *   <li>positions from visual line with soft wrap end;</li>
 * </ul>
 * </pre>
 * <p/>
 * This method allows to answer if caret offset of the given editor points to soft wrap and visual caret position
 * belongs to the visual line where soft wrap end is located.
 *
 * @param editor    target editor
 * @return          <code>true</code> if caret offset of the given editor points to visual position that belongs to
 *                  visual line where soft wrap end is located
 */
public static boolean isCaretAfterSoftWrap(CaretImpl caret) {
  if (!caret.isUpToDate()) {
    return false;
  }
  EditorImpl editor = caret.getEditor();
  SoftWrapModel softWrapModel = editor.getSoftWrapModel();
  int offset = caret.getOffset();
  SoftWrap softWrap = softWrapModel.getSoftWrap(offset);
  if (softWrap == null) {
    return false;
  }

  if (editor.myUseNewRendering) {
    VisualPosition afterWrapPosition = editor.offsetToVisualPosition(offset, false, false);
    VisualPosition caretPosition = caret.getVisualPosition();
    return caretPosition.line == afterWrapPosition.line && caretPosition.column <= afterWrapPosition.column;
  }
  else {
    return editor.offsetToVisualLine(offset) == caret.getVisualPosition().line;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:SoftWrapHelper.java

示例9: getPreferredSize

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
@Override
public Dimension getPreferredSize() {
  if (myPreferredSize == null) {
    int maxLineLength = 0;
    int linesCount = 0;

    for (LineTokenizer lt = new LineTokenizer(myRawText); !lt.atEnd(); lt.advance()) {
      maxLineLength = Math.max(maxLineLength, lt.getLength());
      linesCount++;
    }

    FontMetrics fontMetrics = ((EditorImpl)getEditor()).getFontMetrics(myTextAttributes != null ? myTextAttributes.getFontType() : Font.PLAIN);
    int preferredHeight = getEditor().getLineHeight() * Math.max(1, linesCount);
    int preferredWidth = fontMetrics.charWidth('m') * maxLineLength;

    Insets insets = getInsets();
    if (insets != null) {
      preferredHeight += insets.top + insets.bottom;
      preferredWidth += insets.left + insets.right;
    }

    myPreferredSize = new Dimension(preferredWidth, preferredHeight);
  }
  return myPreferredSize;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:EditorTextFieldCellRenderer.java

示例10: testSoftWrapsRecalculationOnTabWidthChange

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
public void testSoftWrapsRecalculationOnTabWidthChange() throws IOException {
  // Inspired by IDEA-78616 - the point is to recalculate soft wraps when tab width is changed.
  String text = 
    "\t<caret> my text";

  // Build soft wraps cache.
  init(40, text);
  
  VisualPosition caretPositionBefore = getEditor().getCaretModel().getVisualPosition();

  // Change tab size.
  final CommonCodeStyleSettings.IndentOptions indentOptions = getCurrentCodeStyleSettings().getIndentOptions();
  assertNotNull(indentOptions);
  indentOptions.TAB_SIZE++;

  ((EditorImpl)getEditor()).reinitSettings();
  assertEquals(
    new VisualPosition(caretPositionBefore.line, caretPositionBefore.column + 1),
    getEditor().getCaretModel().getVisualPosition()
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SoftWrapApplianceOnDocumentModificationTest.java

示例11: setOrRefreshErrorStripeRenderer

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
static void setOrRefreshErrorStripeRenderer(@NotNull EditorMarkupModel editorMarkupModel,
                                            @NotNull Project project,
                                            @NotNull Document document,
                                            PsiFile file) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  if (!editorMarkupModel.isErrorStripeVisible() || !DaemonCodeAnalyzer.getInstance(project).isHighlightingAvailable(file)) {
    return;
  }
  ErrorStripeRenderer renderer = editorMarkupModel.getErrorStripeRenderer();
  if (renderer instanceof TrafficLightRenderer) {
    TrafficLightRenderer tlr = (TrafficLightRenderer)renderer;
    tlr.refresh();
    ((EditorMarkupModelImpl)editorMarkupModel).repaintVerticalScrollBar();
    if (tlr.myFile == null || tlr.myFile.isValid()) return;
    Disposer.dispose(tlr);
  }
  EditorImpl editor = (EditorImpl)editorMarkupModel.getEditor();

  if (!editor.isDisposed()) {
    renderer = new TrafficLightRenderer(project, document, file);
    Disposer.register(editor.getDisposable(), (Disposable)renderer);
    editorMarkupModel.setErrorStripeRenderer(renderer);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:TrafficLightRenderer.java

示例12: ConsoleGutterComponent

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
public ConsoleGutterComponent(@NotNull Editor editor, @NotNull GutterContentProvider gutterContentProvider, boolean atLineStart) {
  this.editor = (EditorImpl)editor;
  this.gutterContentProvider = gutterContentProvider;
  this.atLineStart = atLineStart;

  if (atLineStart) {
    setOpaque(gutterContentProvider.getLineStartGutterOverlap(editor) == 0);
  }
  else {
    addListeners();
    setOpaque(false);
  }

  int spaceWidth = EditorUtil.getSpaceWidth(Font.PLAIN, editor);
  // at line start: icon/one-char symbol + space
  gap = atLineStart ? spaceWidth * GutterContentProvider.MAX_LINE_END_GUTTER_WIDTH_IN_CHAR : spaceWidth;
  maxContentWidth = atLineStart ? gap : 0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ConsoleGutterComponent.java

示例13: getInjectedEditorForInjectedFile

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
@NotNull
public static Editor getInjectedEditorForInjectedFile(@NotNull Editor hostEditor, @NotNull Caret hostCaret, @Nullable final PsiFile injectedFile) {
  if (injectedFile == null || hostEditor instanceof EditorWindow || hostEditor.isDisposed()) return hostEditor;
  Project project = hostEditor.getProject();
  if (project == null) project = injectedFile.getProject();
  Document document = PsiDocumentManager.getInstance(project).getDocument(injectedFile);
  if (!(document instanceof DocumentWindowImpl)) return hostEditor;
  DocumentWindowImpl documentWindow = (DocumentWindowImpl)document;
  if (hostCaret.hasSelection()) {
    int selstart = hostCaret.getSelectionStart();
    if (selstart != -1) {
      int selend = Math.max(selstart, hostCaret.getSelectionEnd());
      if (!documentWindow.containsRange(selstart, selend)) {
        // selection spreads out the injected editor range
        return hostEditor;
      }
    }
  }
  if (!documentWindow.isValid()) {
    return hostEditor; // since the moment we got hold of injectedFile and this moment call, document may have been dirtied
  }
  return EditorWindowImpl.create(documentWindow, (EditorImpl)hostEditor, injectedFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:InjectedLanguageUtil.java

示例14: openEditorFor

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
public static Editor openEditorFor(@NotNull PsiFile file, @NotNull Project project) {
  Document document = PsiDocumentManager.getInstance(project).getDocument(file);
  // may return editor injected in current selection in the host editor, not for the file passed as argument
  VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) {
    return null;
  }
  if (virtualFile instanceof VirtualFileWindow) {
    virtualFile = ((VirtualFileWindow)virtualFile).getDelegate();
  }
  Editor editor = FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, virtualFile, -1), false);
  if (editor == null || editor instanceof EditorWindow || editor.isDisposed()) return editor;
  if (document instanceof DocumentWindowImpl) {
    return EditorWindowImpl.create((DocumentWindowImpl)document, (EditorImpl)editor, file);
  }
  return editor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:InjectedLanguageUtil.java

示例15: create

import com.intellij.openapi.editor.impl.EditorImpl; //导入依赖的package包/类
public static Editor create(@NotNull final DocumentWindowImpl documentRange, @NotNull final EditorImpl editor, @NotNull final PsiFile injectedFile) {
  assert documentRange.isValid();
  assert injectedFile.isValid();
  EditorWindowImpl window;
  synchronized (allEditors) {
    for (EditorWindowImpl editorWindow : allEditors) {
      if (editorWindow.getDocument() == documentRange && editorWindow.getDelegate() == editor) {
        editorWindow.myInjectedFile = injectedFile;
        if (editorWindow.isValid()) {
          return editorWindow;
        }
      }
      if (editorWindow.getDocument().areRangesEqual(documentRange)) {
        //int i = 0;
      }
    }
    window = new EditorWindowImpl(documentRange, editor, injectedFile, documentRange.isOneLine());
    allEditors.add(window);
  }
  assert window.isValid();
  return window;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:EditorWindowImpl.java


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