Java 类com.intellij.lang.refactoring.InlineActionHandler 实例源码

项目:intellij-ce-playground    文件:InlineRefactoringActionHandler.java   
@Override
public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
  LOG.assertTrue(elements.length == 1);
  if (dataContext == null) {
    dataContext = DataManager.getInstance().getDataContext();
  }
  final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
  for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
    if (handler.canInlineElement(elements[0])) {
      handler.inlineElement(project, editor, elements [0]);
      return;
    }
  }

  invokeInliner(editor, elements[0]);
}
项目:intellij-ce-playground    文件:InlineRefactoringActionHandler.java   
@Override
public void invoke(@NotNull final Project project, Editor editor, PsiFile file, DataContext dataContext) {
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);

  PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
  if (element == null) {
    element = BaseRefactoringAction.getElementAtCaret(editor, file);
  }
  if (element != null) {
    for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
      if (handler.canInlineElementInEditor(element, editor)) {
        handler.inlineElement(project, editor, element);
        return;
      }
    }

    if (invokeInliner(editor, element)) return;

    String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method.or.local.name"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null);
  }
}
项目:tools-idea    文件:InlineRefactoringActionHandler.java   
@Override
public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
  LOG.assertTrue(elements.length == 1);
  if (dataContext == null) {
    dataContext = DataManager.getInstance().getDataContext();
  }
  final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
  for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
    if (handler.canInlineElement(elements[0])) {
      handler.inlineElement(project, editor, elements [0]);
      return;
    }
  }

  invokeInliner(editor, elements[0]);
}
项目:tools-idea    文件:InlineRefactoringActionHandler.java   
@Override
public void invoke(@NotNull final Project project, Editor editor, PsiFile file, DataContext dataContext) {
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);

  PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
  if (element == null) {
    element = BaseRefactoringAction.getElementAtCaret(editor, file);
  }
  if (element != null) {
    for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
      if (handler.canInlineElementInEditor(element, editor)) {
        handler.inlineElement(project, editor, element);
        return;
      }
    }

    if (invokeInliner(editor, element)) return;

    String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method.or.local.name"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null);
  }
}
项目:consulo    文件:InlineRefactoringActionHandler.java   
@Override
public void invoke(@Nonnull Project project, @Nonnull PsiElement[] elements, DataContext dataContext) {
  LOG.assertTrue(elements.length == 1);
  if (dataContext == null) {
    dataContext = DataManager.getInstance().getDataContext();
  }
  final Editor editor = dataContext.getData(PlatformDataKeys.EDITOR);
  for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
    if (handler.canInlineElement(elements[0])) {
      handler.inlineElement(project, editor, elements [0]);
      return;
    }
  }

  invokeInliner(editor, elements[0]);
}
项目:consulo    文件:InlineRefactoringActionHandler.java   
@Override
public void invoke(@Nonnull final Project project, Editor editor, PsiFile file, DataContext dataContext) {
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);

  PsiElement element = dataContext.getData(LangDataKeys.PSI_ELEMENT);
  if (element == null) {
    element = BaseRefactoringAction.getElementAtCaret(editor, file);
  }
  if (element != null) {
    for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
      if (handler.canInlineElementInEditor(element, editor)) {
        handler.inlineElement(project, editor, element);
        return;
      }
    }

    if (invokeInliner(editor, element)) return;

    String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method.or.local.name"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null);
  }
}
项目:intellij-ce-playground    文件:InlineAction.java   
private static boolean hasInlineActionHandler(PsiElement element, @Nullable Language editorLanguage, Editor editor) {
  for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
    if (handler.isEnabledOnElement(element, editor)) {
      return true;
    }
  }
  return InlineHandlers.getInlineHandlers(
    editorLanguage != null ? editorLanguage :element.getLanguage()
  ).size() > 0;
}
项目:intellij-ce-playground    文件:InlineAction.java   
@Override
protected boolean isAvailableForLanguage(Language language) {
  for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
    if (handler.isEnabledForLanguage(language)) {
      return true;
    }
  }
  return InlineHandlers.getInlineHandlers(language).size() > 0;
}
项目:shuffler    文件:InliningVisitor.java   
private void inlineElement(final PsiElement element){
    if (element == null) return;
    if (!(element instanceof PsiModifierListOwner)) return;

    boolean isPublic = ((PsiModifierListOwner) element).hasModifierProperty("public");

    if (isPublic) return;

    for (final InlineActionHandler handler : Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
        if (handler.canInlineElement(element)) {
            handler.inlineElement(element.getProject(), null, element);
            return;
        }
    }
}
项目:tools-idea    文件:InlineAction.java   
private static boolean hasInlineActionHandler(PsiElement element, @Nullable Language editorLanguage, Editor editor) {
  for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
    if (handler.isEnabledOnElement(element, editor)) {
      return true;
    }
  }
  return InlineHandlers.getInlineHandlers(
    editorLanguage != null ? editorLanguage :element.getLanguage()
  ).size() > 0;
}
项目:tools-idea    文件:InlineAction.java   
@Override
protected boolean isAvailableForLanguage(Language language) {
  for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
    if (handler.isEnabledForLanguage(language)) {
      return true;
    }
  }
  return InlineHandlers.getInlineHandlers(language).size() > 0;
}
项目:consulo    文件:InlineAction.java   
private static boolean hasInlineActionHandler(PsiElement element, @Nullable Language editorLanguage, Editor editor) {
  for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
    if (handler.isEnabledOnElement(element, editor)) {
      return true;
    }
  }
  return InlineHandlers.getInlineHandlers(
    editorLanguage != null ? editorLanguage :element.getLanguage()
  ).size() > 0;
}
项目:consulo    文件:InlineAction.java   
@Override
protected boolean isAvailableForLanguage(Language language) {
  for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
    if (handler.isEnabledForLanguage(language)) {
      return true;
    }
  }
  return InlineHandlers.getInlineHandlers(language).size() > 0;
}