com.intellij.lang.LanguageCodeInsightActionHandler Java Examples

The following examples show how to use com.intellij.lang.LanguageCodeInsightActionHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImplementMethodsHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public final void invoke(@Nonnull final Project project, @Nonnull final Editor editor, @Nonnull PsiFile file) {
  if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return;
  if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)){
    return;
  }

  Language language = PsiUtilCore.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
  final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.IMPLEMENT_METHOD.forLanguage(language);
  if (codeInsightActionHandler != null) {
    codeInsightActionHandler.invoke(project, editor, file);
  }
}
 
Example #2
Source File: DelegateMethodsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean isValidForFile(@Nonnull Project project, @Nonnull Editor editor, @Nonnull final PsiFile file) {
  Language language = PsiUtilCore.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
  final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.DELEGATE_METHODS.forLanguage(language);
  if (codeInsightActionHandler != null) {
    return codeInsightActionHandler.isValidFor(editor, file);
  }
  return false;
}
 
Example #3
Source File: OverrideMethodsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean isValidForFile(@Nonnull Project project, @Nonnull Editor editor, @Nonnull final PsiFile file) {
  Language language = PsiUtilCore.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
  final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.OVERRIDE_METHOD.forLanguage(language);
  if (codeInsightActionHandler != null) {
    return codeInsightActionHandler.isValidFor(editor, file);
  }
  return false;
}
 
Example #4
Source File: DelegateMethodsHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public final void invoke(@Nonnull final Project project, @Nonnull final Editor editor, @Nonnull PsiFile file) {
  if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return;
  if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)){
    return;
  }

  Language language = PsiUtilCore.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
  final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.DELEGATE_METHODS.forLanguage(language);
  if (codeInsightActionHandler != null) {
    codeInsightActionHandler.invoke(project, editor, file);
  }
}
 
Example #5
Source File: OverrideMethodsHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public final void invoke(@Nonnull final Project project, @Nonnull final Editor editor, @Nonnull PsiFile file) {
  if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return;
  if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)){
    return;
  }

  Language language = PsiUtilCore.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
  final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.OVERRIDE_METHOD.forLanguage(language);
  if (codeInsightActionHandler != null) {
    codeInsightActionHandler.invoke(project, editor, file);
  }
}
 
Example #6
Source File: ImplementMethodsAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean isValidForFile(@Nonnull Project project, @Nonnull Editor editor, @Nonnull final PsiFile file) {
  final Language language = PsiUtilCore.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
  final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.IMPLEMENT_METHOD.forLanguage(language);
  return codeInsightActionHandler != null && codeInsightActionHandler.isValidFor(editor, file);
}