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