• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DocumentEx类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



DocumentEx类属于com.intellij.openapi.editor.ex包,在下文中一共展示了DocumentEx类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testMoveText

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
public void testMoveText() {
  PsiJavaFile file = (PsiJavaFile)configureByText(JavaFileType.INSTANCE, "class C1{}\nclass C2 {}");
  DocumentEx document = (DocumentEx)file.getViewProvider().getDocument();

  SmartPsiElementPointer<PsiClass> pointer1 =
    createPointer(file.getClasses()[0]);
  SmartPsiElementPointer<PsiClass> pointer2 =
    createPointer(file.getClasses()[1]);
  assertEquals("C1", pointer1.getElement().getName());
  assertEquals("C2", pointer2.getElement().getName());

  PlatformTestUtil.tryGcSoftlyReachableObjects();
  assertNull(((SmartPointerEx) pointer1).getCachedElement());
  assertNull(((SmartPointerEx) pointer2).getCachedElement());

  TextRange range = file.getClasses()[1].getTextRange();
  document.moveText(range.getStartOffset(), range.getEndOffset(), 0);

  System.out.println(pointer1.getRange());
  System.out.println(pointer2.getRange());

  PsiDocumentManager.getInstance(myProject).commitAllDocuments();

  assertEquals("C1", pointer1.getElement().getName());
  assertEquals("C2", pointer2.getElement().getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:SmartPsiElementPointersTest.java


示例2: translatedViaDiff

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
private boolean translatedViaDiff(DocumentEvent e, DocumentEventImpl event) {
  try {
    myLine = event.translateLineViaDiff(myLine);
  }
  catch (FilesTooBigForDiffException ignored) {
    return false;
  }
  if (myLine < 0 || myLine >= getDocument().getLineCount()) {
    invalidate(e);
  }
  else {
    DocumentEx document = getDocument();
    setIntervalStart(document.getLineStartOffset(myLine));
    setIntervalEnd(document.getLineEndOffset(myLine));
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PersistentRangeHighlighterImpl.java


示例3: reinitDocumentIndentOptions

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
private void reinitDocumentIndentOptions() {
  if (myEditor == null) return;
  final Project project = myEditor.getProject();
  final DocumentEx document = myEditor.getDocument();

  if (project == null || project.isDisposed()) return;

  final PsiDocumentManager psiManager = PsiDocumentManager.getInstance(project);
  final PsiFile file = psiManager.getPsiFile(document);
  if (file == null) return;

  CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(project).getCurrentSettings();
  CommonCodeStyleSettings.IndentOptions options = settings.getIndentOptionsByFile(file);

  if (CodeStyleSettings.isRecalculateForCommittedDocument(options)) {
    PsiDocumentManager.getInstance(project).performForCommittedDocument(document, new Runnable() {
      @Override
      public void run() {
        CodeStyleSettingsManager.updateDocumentIndentOptions(project, document);
      }
    });
  }
  else {
    CodeStyleSettingsManager.updateDocumentIndentOptions(project, document);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:SettingsImpl.java


示例4: advance

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
/**
 * Updates state of the current context object in order to point to the end of the given collapsed fold region.
 * 
 * @param foldRegion    collapsed fold region to process
 */
private void advance(FoldRegion foldRegion, int placeHolderWidthInPixels) {
  lastFoldStartPosition = currentPosition.clone();
  lastFold = foldRegion;
  int visualLineBefore = currentPosition.visualLine;
  int logicalLineBefore = currentPosition.logicalLine;
  int logicalColumnBefore = currentPosition.logicalColumn;
  currentPosition.advance(foldRegion, -1);
  currentPosition.x += placeHolderWidthInPixels;
  int collapsedFoldingWidthInColumns = currentPosition.logicalColumn;
  if (currentPosition.logicalLine <= logicalLineBefore) {
    // Single-line fold region.
    collapsedFoldingWidthInColumns = currentPosition.logicalColumn - logicalColumnBefore;
  }
  else {
    final DocumentEx document = myEditor.getDocument();
    int endFoldLine = document.getLineNumber(foldRegion.getEndOffset());
    logicalLineData.endLineOffset = document.getLineEndOffset(endFoldLine);
  }
  notifyListenersOnFoldRegion(foldRegion, collapsedFoldingWidthInColumns, visualLineBefore);
  tokenStartOffset = myContext.currentPosition.offset;
  softWrapStartOffset = foldRegion.getEndOffset();
  lastFoldEndPosition = currentPosition.clone();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:SoftWrapApplianceManager.java


示例5: testSaveDocument_DoNotSaveIfModStampEqualsToFile

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
public void testSaveDocument_DoNotSaveIfModStampEqualsToFile() throws Exception {
  final VirtualFile file = createFile();
  final DocumentEx document = (DocumentEx)myDocumentManager.getDocument(file);
  assertNotNull(file.toString(), document);
  WriteCommandAction.runWriteCommandAction(myProject, new Runnable() {
    @Override
    public void run() {
      document.insertString(0, "zzz");
      document.setModificationStamp(file.getModificationStamp());
    }
  });

  getProject().getMessageBus().connect(getTestRootDisposable()).subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
    @Override
    public void beforeDocumentSaving(@NotNull Document documentToSave) {
      assertNotSame(document, documentToSave);
    }
  });

  myDocumentManager.saveDocument(document);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:FileDocumentManagerImplTest.java


示例6: testSuccessiveBulkModeOperations

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
public void testSuccessiveBulkModeOperations() throws Exception {
  initText("some text");
  DocumentEx document = (DocumentEx)myEditor.getDocument();
  
  document.setInBulkUpdate(true);
  document.replaceString(4, 5, "-");
  document.setInBulkUpdate(false);
  
  myEditor.getCaretModel().moveToOffset(9);
  
  document.setInBulkUpdate(true);
  document.replaceString(4, 5, "+");
  document.setInBulkUpdate(false);
  
  checkResultByText("some+text<caret>");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EditorImplTest.java


示例7: RangeMarkerImpl

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
private RangeMarkerImpl(@NotNull DocumentEx document, int start, int end, boolean register, boolean greedyToLeft, boolean greedyToRight) {
  if (start < 0) {
    throw new IllegalArgumentException("Wrong start: " + start+"; end="+end);
  }
  if (end > document.getTextLength()) {
    throw new IllegalArgumentException("Wrong end: " + end+ "; document length="+document.getTextLength()+"; start="+start);
  }
  if (start > end){
    throw new IllegalArgumentException("start > end: start=" + start+"; end="+end);
  }

  myDocument = document;
  myId = counter.next();
  if (register) {
    registerInTree(start, end, greedyToLeft, greedyToRight, 0);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:RangeMarkerImpl.java


示例8: doSync

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
private void doSync(@NotNull final PsiTreeChangeEvent event, boolean force, @NotNull final DocSyncAction syncAction) {
  if (!toProcessPsiEvent()) return;
  final PsiFile psiFile = event.getFile();
  if (!(psiFile instanceof PsiFileEx) || !((PsiFileEx)psiFile).isContentsLoaded()) return;

  final DocumentEx document = getCachedDocument(psiFile, force);
  if (document == null) return;

  performAtomically(psiFile, new Runnable() {
    @Override
    public void run() {
      syncAction.syncDocument(document, (PsiTreeChangeEventImpl)event);
    }
  });

  final boolean insideTransaction = myTransactionsMap.containsKey(document);
  if (!insideTransaction) {
    document.setModificationStamp(psiFile.getViewProvider().getModificationStamp());
    if (LOG.isDebugEnabled()) {
      PsiDocumentManagerBase.checkConsistency(psiFile, document);
    }
  }

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PsiToDocumentSynchronizer.java


示例9: doCommitTransaction

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
private static void doCommitTransaction(@NotNull Document document, @NotNull DocumentChangeTransaction documentChangeTransaction) {
  DocumentEx ex = (DocumentEx) document;
  ex.suppressGuardedExceptions();
  try {
    boolean isReadOnly = !document.isWritable();
    ex.setReadOnly(false);

    for (Map.Entry<TextRange, CharSequence> entry : documentChangeTransaction.myAffectedFragments.descendingMap().entrySet()) {
      ex.replaceString(entry.getKey().getStartOffset(), entry.getKey().getEndOffset(), entry.getValue());
    }

    ex.setReadOnly(isReadOnly);
  }
  finally {
    ex.unSuppressGuardedExceptions();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PsiToDocumentSynchronizer.java


示例10: getLastCommittedDocument

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
@NotNull
public DocumentEx getLastCommittedDocument(@NotNull Document document) {
  if (document instanceof FrozenDocument) return (DocumentEx)document;

  if (document instanceof DocumentWindow) {
    DocumentWindow window = (DocumentWindow)document;
    Document delegate = window.getDelegate();
    if (delegate instanceof FrozenDocument) return (DocumentEx)window;

    UncommittedInfo info = myUncommittedInfos.get(delegate);
    DocumentWindow answer = info == null ? null : info.myFrozenWindows.get(document);
    if (answer == null) answer = freezeWindow(window);
    if (info != null) answer = ConcurrencyUtil.cacheOrGet(info.myFrozenWindows, window, answer);
    return (DocumentEx)answer;
  }

  assert document instanceof DocumentImpl;
  UncommittedInfo info = myUncommittedInfos.get(document);
  return info != null ? info.myFrozen : ((DocumentImpl)document).freeze();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PsiDocumentManagerBase.java


示例11: rememberDocumentState

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
private static Runnable rememberDocumentState(final Editor _editor) {
  final Editor editor = InjectedLanguageUtil.getTopLevelEditor(_editor);
  final String documentText = editor.getDocument().getText();
  final int caret = editor.getCaretModel().getOffset();
  final int selStart = editor.getSelectionModel().getSelectionStart();
  final int selEnd = editor.getSelectionModel().getSelectionEnd();

  final int vOffset = editor.getScrollingModel().getVerticalScrollOffset();
  final int hOffset = editor.getScrollingModel().getHorizontalScrollOffset();

  return new Runnable() {
    @Override
    public void run() {
      DocumentEx document = (DocumentEx) editor.getDocument();

      document.replaceString(0, document.getTextLength(), documentText);
      editor.getCaretModel().moveToOffset(caret);
      editor.getSelectionModel().setSelection(selStart, selEnd);

      editor.getScrollingModel().scrollHorizontally(hOffset);
      editor.getScrollingModel().scrollVertically(vOffset);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CodeCompletionHandlerBase.java


示例12: updateStatus

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
private void updateStatus() {
  Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
  if (editor == null || !editor.getContentComponent().hasFocus()){
    return;
  }

  final Document document = editor.getDocument();
  if (document instanceof DocumentEx && ((DocumentEx)document).isInBulkUpdate()) return;

  int offset = editor.getCaretModel().getOffset();
  DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject);
  HighlightInfo info = ((DaemonCodeAnalyzerImpl)codeAnalyzer).findHighlightByOffset(document, offset, false, HighlightSeverity.WARNING);
  String text = info != null && info.getDescription() != null ? info.getDescription() : "";

  StatusBar statusBar = WindowManager.getInstance().getStatusBar(editor.getContentComponent(), myProject);
  if (statusBar != null && !text.equals(statusBar.getInfo())) {
    statusBar.setInfo(text, "updater");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StatusBarUpdater.java


示例13: documentChanged

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
@Override
public void documentChanged(DocumentEvent event) {
  DocumentEx document = getDocument();
  if (document.isInBulkUpdate()) {
    return;
  }

  if (document.getTextLength() > 0) {
    addLineSeparatorPainterIfNeed();
    int startDocLine = document.getLineNumber(event.getOffset());
    int endDocLine = document.getLineNumber(event.getOffset() + event.getNewLength());
    if (event.getOldLength() > event.getNewLength() || startDocLine != endDocLine || StringUtil.indexOf(event.getOldFragment(), '\n') != -1) {
      updateGutterSize(startDocLine, endDocLine);
    }
  }
  else if (event.getOldLength() > 0) {
    documentCleared();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:LanguageConsoleBuilder.java


示例14: compute

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
@Override
public CachedValueProvider.Result<MultiHostRegistrarImpl> compute(PsiElement element) {
  PsiFile hostPsiFile = element.getContainingFile();
  if (hostPsiFile == null) return null;
  FileViewProvider viewProvider = hostPsiFile.getViewProvider();
  final DocumentEx hostDocument = (DocumentEx)viewProvider.getDocument();
  if (hostDocument == null) return null;

  PsiManager psiManager = viewProvider.getManager();
  final Project project = psiManager.getProject();
  InjectedLanguageManagerImpl injectedManager = InjectedLanguageManagerImpl.getInstanceImpl(project);

  final MultiHostRegistrarImpl result = doCompute(element, injectedManager, project, hostPsiFile);

  return CachedValueProvider.Result.create(result, PsiModificationTracker.MODIFICATION_COUNT, hostDocument);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:InjectedPsiCachedValueProvider.java


示例15: setDone

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
@Override
protected void setDone(boolean done) {
  super.setDone(done);

  if (myResetBulkUpdateState) {
    DocumentEx document = getAffectedDocument(myModel);
    if (document != null) {
      document.setInBulkUpdate(false);
      myResetBulkUpdateState = false;
    }
  }

  if (done) {
    myModel.commitChanges();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:FormatProcessor.java


示例16: updateRawHtmlText

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
protected void updateRawHtmlText(final String htmlTxt) {
    final DocumentEx myDocument = myTextViewer.getDocument();

    if (project.isDisposed()) return;

    ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
            if (project.isDisposed()) return;

            CommandProcessor.getInstance().executeCommand(project, new Runnable() {
                @Override
                public void run() {
                    if (project.isDisposed()) return;

                    myDocument.replaceString(0, myDocument.getTextLength(), htmlTxt);
                    final CaretModel caretModel = myTextViewer.getCaretModel();
                    if (caretModel.getOffset() >= myDocument.getTextLength()) {
                        caretModel.moveToOffset(myDocument.getTextLength());
                    }
                }
            }, null, null, UndoConfirmationPolicy.DEFAULT, myDocument);
        }
    });
}
 
开发者ID:vsch,项目名称:idea-multimarkdown,代码行数:26,代码来源:MultiMarkdownPreviewEditor.java


示例17: createSelection

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
public static SelectionDescription createSelection(final Editor editor, final int lineIndex) {
  return new SelectionDescription(editor) {
    public void select() {
      if(myIsActive) return;
      myIsActive = true;
      DocumentEx doc = (DocumentEx)editor.getDocument();
      editor.getSelectionModel().setSelection(
        doc.getLineStartOffset(lineIndex),
        doc.getLineEndOffset(lineIndex) + doc.getLineSeparatorLength(lineIndex)
      );
    }

    public void remove() {
      if(!myIsActive) return;
      myIsActive = false;
      myEditor.getSelectionModel().removeSelection();
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:PositionHighlighter.java


示例18: EditorChangeAction

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
public EditorChangeAction(DocumentEx document,
                          int offset,
                          CharSequence oldString,
                          CharSequence newString,
                          long oldTimeStamp) {
  super(document);

  Charset charset = EncodingManager.getInstance().getEncoding(FileDocumentManager.getInstance().getFile(document), false);
  myCharset = charset == null ? Charset.defaultCharset() : charset;

  myOffset = offset;
  myOldString = oldString == null ? "" : compressCharSequence(oldString, myCharset);
  myNewString = newString == null ? "" : compressCharSequence(newString, myCharset);
  myOldTimeStamp = oldTimeStamp;
  myNewTimeStamp = document.getModificationStamp();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:EditorChangeAction.java


示例19: createIterator

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
@Override
public HighlighterIterator createIterator(int startOffset) {
  synchronized (this) {
    final Document document = getDocument();
    if(document instanceof DocumentEx && ((DocumentEx)document).isInBulkUpdate()) {
      ((DocumentEx)document).setInBulkUpdate(false); // bulk mode failed
    }

    if (mySegments.getSegmentCount() == 0 && document != null && document.getTextLength() > 0) {
      // bulk mode was reset
      doSetText(document.getCharsSequence());
    }

    final int latestValidOffset = mySegments.getLastValidOffset();
    return new HighlighterIteratorImpl(startOffset <= latestValidOffset ? startOffset : latestValidOffset);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:LexerEditorHighlighter.java


示例20: RangeHighlighterImpl

import com.intellij.openapi.editor.ex.DocumentEx; //导入依赖的package包/类
RangeHighlighterImpl(@NotNull MarkupModel model,
                     int start,
                     int end,
                     int layer,
                     @NotNull HighlighterTargetArea target,
                     TextAttributes textAttributes, boolean greedyToLeft, boolean greedyToRight) {
  super((DocumentEx)model.getDocument(), start, end,false);

  data = new RangeHighlighterData(model, target, textAttributes) {
    @NotNull
    @Override
    public RangeHighlighterEx getRangeHighlighter() {
      return RangeHighlighterImpl.this;
    }
  };

  registerInTree(start, end, greedyToLeft, greedyToRight, layer);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:RangeHighlighterImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DEmptyPattern类代码示例发布时间:2022-05-23
下一篇:
Java LeafSchemaNode类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap