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


Java EditorUtil.fillVirtualSpaceUntilCaret方法代码示例

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


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

示例1: checkResultByFile

import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
private void checkResultByFile(@NonNls @NotNull String expectedFile,
                               @NotNull PsiFile originalFile,
                               boolean stripTrailingSpaces) throws IOException {
  if (!stripTrailingSpaces) {
    EditorUtil.fillVirtualSpaceUntilCaret(myEditor);
  }
  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();

  final String fileText = originalFile.getText();
  final String path = getTestDataPath() + "/" + expectedFile;

  /*final VirtualFile result = LocalFileSystem.getInstance().findFileByPath(path);
  final int caret = myEditor.getCaretModel().getOffset();
  final String newText = myFile == originalFile ? fileText.substring(0, caret) + "<caret>" + fileText.substring(caret) : fileText;
  VfsUtil.saveText(result, newText);*/

  VirtualFile virtualFile = originalFile.getVirtualFile();
  String charset = virtualFile == null? null : virtualFile.getCharset().name();
  checkResult(expectedFile, stripTrailingSpaces, SelectionAndCaretMarkupLoader.fromFile(path, charset), fileText);

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

示例2: checkResultByFile

import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
/**
 * Validates that content of the editor as well as caret and selection matches one specified in data file that
 * should be formed with the same format as one used in configureByFile
 * @param message - this check specific message. Added to text, caret position, selection checking. May be null
 * @param filePath - relative path from %IDEA_INSTALLATION_HOME%/testData/
 * @param ignoreTrailingSpaces - whether trailing spaces in editor in data file should be stripped prior to comparing.
 */
protected void checkResultByFile(@Nullable String message, @TestDataFile @NotNull String filePath, final boolean ignoreTrailingSpaces) {
  bringRealEditorBack();

  getProject().getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
  if (ignoreTrailingSpaces) {
    final Editor editor = myEditor;
    TrailingSpacesStripper.stripIfNotCurrentLine(editor.getDocument(), false);
    EditorUtil.fillVirtualSpaceUntilCaret(editor);
  }

  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();

  String fullPath = getTestDataPath() + filePath;

  File ioFile = new File(fullPath);

  assertTrue(getMessage("Cannot find file " + fullPath, message), ioFile.exists());
  String fileText = null;
  try {
    fileText = FileUtil.loadFile(ioFile, CharsetToolkit.UTF8_CHARSET);
  } catch (IOException e) {
    LOG.error(e);
  }
  checkResultByText(message, StringUtil.convertLineSeparators(fileText), ignoreTrailingSpaces, getTestDataPath() + "/" + filePath);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:LightPlatformCodeInsightTestCase.java

示例3: invoke

import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
  if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return;
  if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)) {
    return;
  }
  EditorUtil.fillVirtualSpaceUntilCaret(editor);

  PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
  int offset = editor.getCaretModel().getOffset();
  List<TemplateImpl> applicableTemplates = TemplateManagerImpl.listApplicableTemplateWithInsertingDummyIdentifier(editor, file, false);

  Map<TemplateImpl, String> matchingTemplates = filterTemplatesByPrefix(applicableTemplates, editor, offset, false, true);
  MultiMap<String, CustomLiveTemplateLookupElement> customTemplatesLookupElements = getCustomTemplatesLookupItems(editor, file, offset);

  if (matchingTemplates.isEmpty()) {
    for (TemplateImpl template : applicableTemplates) {
      matchingTemplates.put(template, null);
    }
  }

  if (matchingTemplates.isEmpty() && customTemplatesLookupElements.isEmpty()) {
    HintManager.getInstance().showErrorHint(editor, CodeInsightBundle.message("templates.no.defined"));
    return;
  }

  showTemplatesLookup(project, editor, file, matchingTemplates, customTemplatesLookupElements);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ListTemplatesHandler.java


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