本文整理汇总了Java中com.intellij.codeInsight.CodeInsightActionHandler类的典型用法代码示例。如果您正苦于以下问题:Java CodeInsightActionHandler类的具体用法?Java CodeInsightActionHandler怎么用?Java CodeInsightActionHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CodeInsightActionHandler类属于com.intellij.codeInsight包,在下文中一共展示了CodeInsightActionHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformedImpl
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
public void actionPerformedImpl(@NotNull final Project project, final Editor editor) {
if (editor == null) return;
//final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
if (psiFile == null) return;
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
final CodeInsightActionHandler handler = getHandler();
final Runnable action = new Runnable() {
@Override
public void run() {
if (!ApplicationManager.getApplication().isUnitTestMode() && !editor.getContentComponent().isShowing()) return;
handler.invoke(project, editor, psiFile);
}
};
if (handler.startInWriteAction()) {
ApplicationManager.getApplication().runWriteAction(action);
}
else {
action.run();
}
}
}, getCommandName(), DocCommandGroupId.noneGroupId(editor.getDocument()));
}
示例2: invoke
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
int offset = editor.getCaretModel().getOffset();
final Language language = PsiUtilCore.getLanguageAtOffset(file, offset);
final CodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.GOTO_SUPER.forLanguage(language);
if (codeInsightActionHandler != null) {
DumbService.getInstance(project).withAlternativeResolveEnabled(new Runnable() {
@Override
public void run() {
codeInsightActionHandler.invoke(project, editor, file);
}
});
}
}
示例3: getValidHandler
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
@Nullable
private CodeInsightActionHandler getValidHandler(@NotNull Editor editor, @NotNull PsiFile file) {
Language language = PsiUtilCore.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
final CodeInsightActionHandler codeInsightActionHandler = getLanguageExtension().forLanguage(language);
if (codeInsightActionHandler != null) {
if (codeInsightActionHandler instanceof LanguageCodeInsightActionHandler) {
if (((LanguageCodeInsightActionHandler)codeInsightActionHandler).isValidFor(editor, file)) {
return codeInsightActionHandler;
}
}
else {
return codeInsightActionHandler;
}
}
return null;
}
示例4: getHandler
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new CodeInsightActionHandler() {
@Override
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
String templateText = EmmetPreviewUtil.calculateTemplateText(editor, file, true);
if (StringUtil.isEmpty(templateText)) {
CommonRefactoringUtil.showErrorHint(project, editor, "Cannot show preview for given abbreviation", "Emmet Preview", null);
return;
}
EmmetPreviewHint.createHint((EditorEx)editor, templateText, file.getFileType()).showHint();
EmmetPreviewUtil.addEmmetPreviewListeners(editor, file, true);
}
@Override
public boolean startInWriteAction() {
return false;
}
};
}
示例5: getHandler
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new CodeInsightActionHandler() {
@Override
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile psiFile) {
if(invokePhpClass(project, editor)) {
return;
}
if(isValidForFile(psiFile) && invokeFile(project, editor)) {
return;
}
}
@Override
public boolean startInWriteAction() {
return false;
}
};
}
示例6: actionPerformedImpl
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
@RequiredDispatchThread
public void actionPerformedImpl(@Nonnull final Project project, final Editor editor) {
if (editor == null) return;
//final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
if (psiFile == null) return;
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
final CodeInsightActionHandler handler = getHandler();
final Runnable action = new Runnable() {
@Override
public void run() {
if (!ApplicationManager.getApplication().isUnitTestMode() && !editor.getContentComponent().isShowing()) return;
handler.invoke(project, editor, psiFile);
}
};
if (handler.startInWriteAction()) {
ApplicationManager.getApplication().runWriteAction(action);
}
else {
action.run();
}
}
}, getCommandName(), DocCommandGroupId.noneGroupId(editor.getDocument()));
}
示例7: getHandler
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
@Nonnull
@Override
protected CodeInsightActionHandler getHandler() {
return new CodeInsightActionHandler() {
@RequiredDispatchThread
@Override
public void invoke(@Nonnull Project project, @Nonnull Editor editor, @Nonnull PsiFile file) {
DocumentationManager.getInstance(project).showJavaDocInfo(editor, file, LookupManager.getActiveLookup(editor) == null);
}
@Override
public boolean startInWriteAction() {
return false;
}
};
}
示例8: registerHandlerForComplementaryAction
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
private static void registerHandlerForComplementaryAction(final Project project,
final Editor editor,
final PsiElement aClass,
final boolean toImplement,
final MemberChooser<PsiMethodMember> chooser) {
final JComponent preferredFocusedComponent = chooser.getPreferredFocusedComponent();
final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
@NonNls final String s = toImplement ? "OverrideMethods" : "ImplementMethods";
final Shortcut[] shortcuts = keymap.getShortcuts(s);
if (shortcuts.length > 0 && shortcuts[0] instanceof KeyboardShortcut) {
preferredFocusedComponent.getInputMap().put(
((KeyboardShortcut)shortcuts[0]).getFirstKeyStroke(), s
);
preferredFocusedComponent.getActionMap().put(
s,
new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent e) {
chooser.close(DialogWrapper.CANCEL_EXIT_CODE);
// invoke later in order to close previous modal dialog
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
final CodeInsightActionHandler handler = toImplement ? new OverrideMethodsHandler(): new ImplementMethodsHandler();
handler.invoke(project, editor, aClass.getContainingFile());
}
});
}
}
);
}
}
示例9: getHandler
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new CodeInsightActionHandler() {
@Override
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
DocumentationManager.getInstance(project).showJavaDocInfo(editor, file, LookupManager.getActiveLookup(editor) == null);
}
@Override
public boolean startInWriteAction() {
return false;
}
};
}
示例10: update
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
@Override
protected void update(@NotNull Presentation presentation, @NotNull Project project,
@NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext dataContext, @Nullable String actionPlace) {
// avoid evaluating isValidFor several times unnecessary
CodeInsightActionHandler handler = getValidHandler(editor, file);
presentation.setEnabled(handler != null);
if (handler instanceof ContextAwareActionHandler && !ActionPlaces.isMainMenuOrActionSearch(actionPlace)) {
presentation.setVisible(((ContextAwareActionHandler)handler).isAvailableForQuickList(editor, file, dataContext));
}
if (presentation.isVisible() && handler instanceof PresentableCodeInsightActionHandler) {
((PresentableCodeInsightActionHandler)handler).update(editor, file, presentation);
}
}
示例11: getHandler
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
@Override
@NotNull
protected CodeInsightActionHandler getHandler() {
return new CodeInsightActionHandler() {
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
final Runnable runnable = new Runnable() {
@Override
public void run() {
final DomElement element = myProvider.generate(project, editor, file);
myProvider.navigate(element);
}
};
if (GenerateDomElementAction.this.startInWriteAction()) {
new WriteCommandAction(project, file) {
@Override
protected void run(@NotNull final Result result) throws Throwable {
runnable.run();
}
}.execute();
}
else {
runnable.run();
}
}
@Override
public boolean startInWriteAction() {
return false;
}
};
}
示例12: getHandler
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new CodeInsightActionHandler() {
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
final XmlTag tag = findTag(editor, file);
if (tag != null) {
new EmmetAbbreviationBalloon(EMMET_RECENT_UPDATE_ABBREVIATIONS_KEY, EMMET_LAST_UPDATE_ABBREVIATIONS_KEY,
new EmmetAbbreviationBalloon.Callback() {
@Override
public void onEnter(@NotNull String abbreviation) {
try {
doUpdateTag(abbreviation, tag, file, editor);
}
catch (EmmetException ignore) {
}
}
}, XmlBundle.message("emmet.update.tag.title")).show(new CustomTemplateCallback(editor, file));
}
}
@Override
public boolean startInWriteAction() {
return false;
}
};
}
示例13: doTest
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
private void doTest() throws Throwable {
final List<String> data = TestUtils.readInput(getTestDataPath() + getTestName(true) + ".test");
myFixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, data.get(0));
final CodeInsightActionHandler handler = CodeInsightActions.GOTO_SUPER.forLanguage(GroovyLanguage.INSTANCE);
handler.invoke(getProject(), myFixture.getEditor(), myFixture.getFile());
myFixture.checkResult(data.get(1));
}
示例14: invoke
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
int offset = editor.getCaretModel().getOffset();
final Language language = PsiUtilBase.getLanguageAtOffset(file, offset);
final CodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.GOTO_SUPER.forLanguage(language);
if (codeInsightActionHandler != null) {
codeInsightActionHandler.invoke(project, editor, file);
}
}
示例15: getHandler
import com.intellij.codeInsight.CodeInsightActionHandler; //导入依赖的package包/类
@NotNull
protected CodeInsightActionHandler getHandler() {
return new CodeInsightActionHandler() {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
final Runnable runnable = new Runnable() {
public void run() {
final DomElement element = myProvider.generate(project, editor, file);
myProvider.navigate(element);
}
};
if (GenerateDomElementAction.this.startInWriteAction()) {
new WriteCommandAction(project, file) {
protected void run(final Result result) throws Throwable {
runnable.run();
}
}.execute();
}
else {
runnable.run();
}
}
public boolean startInWriteAction() {
return false;
}
};
}