本文整理了Java中com.intellij.openapi.editor.Editor.getProject()
方法的一些代码示例,展示了Editor.getProject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Editor.getProject()
方法的具体详情如下:
包路径:com.intellij.openapi.editor.Editor
类名称:Editor
方法名:getProject
暂无
代码示例来源:origin: JetBrains/ideavim
@Nullable
private Editor selectEditor(@NotNull Editor editor, @NotNull VirtualFile file) {
return VimPlugin.getFile().selectEditor(editor.getProject(), file);
}
代码示例来源:origin: JetBrains/ideavim
@Nullable
public static PsiFile getFile(@NotNull Editor editor) {
VirtualFile vf = EditorData.getVirtualFile(editor);
if (vf != null) {
Project proj = editor.getProject();
if (proj != null) {
PsiManager mgr = PsiManager.getInstance(proj);
return mgr.findFile(vf);
}
}
return null;
}
}
代码示例来源:origin: JetBrains/ideavim
public void run() {
deactivate(true);
final Project project = myEditor.getProject();
if (project != null && e != null && e.getKeyChar() != '\n') {
final KeyStroke key = KeyStroke.getKeyStrokeForEvent(e);
final List<KeyStroke> keys = new ArrayList<KeyStroke>(1);
keys.add(key);
VimPlugin.getMacro().playbackKeys(myEditor, new EditorDataContext(myEditor), project, keys, 0, 0, 1);
}
}
});
代码示例来源:origin: JetBrains/ideavim
/**
* Returns the object corresponding to the specified data identifier. Some of the supported data identifiers are
* defined in the {@link PlatformDataKeys} class.
*
* @param dataId the data identifier for which the value is requested.
* @return the value, or null if no value is available in the current context for this identifier.
*/
public Object getData(String dataId) {
if (PlatformDataKeys.EDITOR.getName().equals(dataId)) {
return editor;
}
else if (PlatformDataKeys.PROJECT.getName().equals(dataId)) {
return editor.getProject();
}
else if (PlatformDataKeys.VIRTUAL_FILE.getName().equals(dataId)) {
return EditorData.getVirtualFile(editor);
}
return null;
}
代码示例来源:origin: JetBrains/ideavim
/**
* Checks if the editor is a primary editor in the main editing area.
*/
private boolean isPrimaryEditor(@NotNull Editor editor) {
final Project project = editor.getProject();
if (project == null) return false;
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
return StreamEx.of(fileEditorManager.getAllEditors())
.anyMatch(fileEditor -> editor.equals(EditorUtil.getEditorEx(fileEditor)));
}
代码示例来源:origin: JetBrains/ideavim
private void handleEditorReset(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull final DataContext context) {
if (state != State.COMMAND && count == 0 && currentArg == Argument.Type.NONE && currentCmd.size() == 0) {
RegisterGroup register = VimPlugin.getRegister();
if (register.getCurrentRegister() == register.getDefaultRegister()) {
if (key.getKeyCode() == KeyEvent.VK_ESCAPE) {
CommandProcessor.getInstance().executeCommand(editor.getProject(), new Runnable() {
@Override
public void run() {
KeyHandler.executeAction("EditorEscape", context);
}
}, "", null);
}
VimPlugin.indicateError();
}
}
reset(editor);
}
代码示例来源:origin: JetBrains/ideavim
private static void resetCursor(@NotNull Editor editor, boolean insert) {
Document doc = editor.getDocument();
VirtualFile vf = FileDocumentManager.getInstance().getFile(doc);
if (vf != null) {
resetCursor(vf, editor.getProject(), insert);
}
else {
editor.getSettings().setBlockCursor(!insert);
}
}
代码示例来源:origin: JetBrains/ideavim
Project project = editor.getProject();
if (project != null) {
VirtualFile root = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(vf);
代码示例来源:origin: JetBrains/ideavim
private void deinitLineNumbers(@NotNull Editor editor) {
editor.getCaretModel().removeCaretListener(myLineNumbersCaretListener);
EditorData.setEditorGroup(editor, false);
editor.getGutter().closeAllAnnotations();
final Project project = editor.getProject();
if (project == null || project.isDisposed()) return;
editor.getSettings().setLineNumbersShown(EditorData.isLineNumbersShown(editor));
}
代码示例来源:origin: JetBrains/ideavim
/**
* This processes all "regular" keystrokes entered while in insert/replace mode
*
* @param editor The editor the character was typed into
* @param context The data context
* @param key The user entered keystroke
* @return true if this was a regular character, false if not
*/
public boolean processKey(@NotNull final Editor editor, @NotNull final DataContext context,
@NotNull final KeyStroke key) {
if (logger.isDebugEnabled()) {
logger.debug("processKey(" + key + ")");
}
if (key.getKeyChar() != KeyEvent.CHAR_UNDEFINED) {
final Document doc = editor.getDocument();
CommandProcessor.getInstance().executeCommand(editor.getProject(),
() -> ApplicationManager.getApplication().runWriteAction(
() -> KeyHandler.getInstance().getOriginalHandler().execute(
editor, key.getKeyChar(), context)), "", doc,
UndoConfirmationPolicy.DEFAULT, doc);
return true;
}
return false;
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Override
public void execute(@NotNull Editor editor, char c, @NotNull DataContext dataContext) {
if (myOriginalHandler != null) myOriginalHandler.execute(editor, c, dataContext);
if (c != 'e') return;
Project project = editor.getProject();
if (project == null) return;
int offset = editor.getCaretModel().getOffset();
if (offset < 4) return;
TextRange from = TextRange.from(offset - 4, 4);
String text = editor.getDocument().getText(from);
if ("case".equals(text)) {
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
ApplicationManager.getApplication().runWriteAction(() -> {
if (project.isDisposed()) return;
PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
if (file == null) return;
CodeStyleManager.getInstance(project).adjustLineIndent(file, from);
});
}
}
}
代码示例来源:origin: JetBrains/ideavim
@Override
public void run() {
if (editor.isDisposed()) {
return;
}
final List<KeyStroke> toKeys = mappingInfo.getToKeys();
final VimExtensionHandler extensionHandler = mappingInfo.getExtensionHandler();
final EditorDataContext currentContext = new EditorDataContext(editor);
if (toKeys != null) {
final boolean fromIsPrefix = isPrefix(mappingInfo.getFromKeys(), toKeys);
boolean first = true;
for (KeyStroke keyStroke : toKeys) {
final boolean recursive = mappingInfo.isRecursive() && !(first && fromIsPrefix);
handleKey(editor, keyStroke, currentContext, recursive);
first = false;
}
}
else if (extensionHandler != null) {
final CommandProcessor processor = CommandProcessor.getInstance();
processor.executeCommand(editor.getProject(),
() -> extensionHandler.execute(editor, context),
"Vim " + extensionHandler.getClass().getSimpleName(),
null);
}
if (prevMappingInfo != null) {
handleKey(editor, key, currentContext);
}
}
};
代码示例来源:origin: JetBrains/ideavim
Project project = editor.getProject();
final Command.Type type = cmd.getType();
if (type.isWrite() && !editor.getDocument().isWritable()) {
代码示例来源:origin: ballerina-platform/ballerina-lang
public void handleInsert(InsertionContext context, LookupElement item) {
Editor editor = context.getEditor();
char completionChar = context.getCompletionChar();
if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) {
return;
}
Project project = editor.getProject();
if (project != null) {
int completionCharOffset = getCompletionCharOffset(editor);
if (completionCharOffset == -1) {
EditorModificationUtil.insertStringAtCaret(editor, ";", false, 1);
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
} else {
editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1);
}
if (myTriggerAutoPopup) {
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
}
}
}
代码示例来源:origin: ballerina-platform/ballerina-lang
public void handleInsert(InsertionContext context, LookupElement item) {
Editor editor = context.getEditor();
char completionChar = context.getCompletionChar();
if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) {
return;
}
Project project = editor.getProject();
if (project != null) {
int completionCharOffset = getCompletionCharOffset(editor);
if (completionCharOffset == -1) {
EditorModificationUtil.insertStringAtCaret(editor, " {}", false, 2);
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
} else {
editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1);
}
if (myTriggerAutoPopup) {
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
}
}
}
代码示例来源:origin: ballerina-platform/ballerina-lang
public void handleInsert(InsertionContext context, LookupElement item) {
Editor editor = context.getEditor();
char completionChar = context.getCompletionChar();
if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) {
return;
}
Project project = editor.getProject();
if (project != null) {
int completionCharOffset = getCompletionCharOffset(editor);
if (completionCharOffset == -1) {
EditorModificationUtil.insertStringAtCaret(editor, "()", false, 1);
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
} else {
editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1);
}
if (myTriggerAutoPopup) {
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
}
}
}
代码示例来源:origin: ballerina-platform/ballerina-lang
public void handleInsert(InsertionContext context, LookupElement item) {
Editor editor = context.getEditor();
char completionChar = context.getCompletionChar();
if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) {
return;
}
Project project = editor.getProject();
if (project != null) {
int completionCharOffset = getCompletionCharOffset(editor);
if (completionCharOffset == -1) {
EditorModificationUtil.insertStringAtCaret(editor, "();", false, 1);
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
} else {
editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1);
}
if (myTriggerAutoPopup) {
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
}
}
}
代码示例来源:origin: ballerina-platform/ballerina-lang
public void handleInsert(InsertionContext context, LookupElement item) {
Editor editor = context.getEditor();
char completionChar = context.getCompletionChar();
if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) {
return;
}
Project project = editor.getProject();
if (project != null) {
int completionCharOffset = getCompletionCharOffset(editor);
if (completionCharOffset == -1) {
EditorModificationUtil.insertStringAtCaret(editor, ":", false, 1);
if (myWithSpace) {
EditorModificationUtil.insertStringAtCaret(editor, " ", false, 1);
}
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
} else {
editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1);
}
if (myTriggerAutoPopup) {
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
}
}
}
代码示例来源:origin: ballerina-platform/ballerina-lang
Project project = editor.getProject();
if (suggestAlias) {
alias = Messages.showInputDialog(project, "Package '" + ((PsiDirectory) element).getName() +
代码示例来源:origin: ballerina-platform/ballerina-lang
return;
Project project = editor.getProject();
if (project != null) {
int completionCharOffset = getCompletionCharOffset(editor);
内容来源于网络,如有侵权,请联系作者删除!