Java 类com.intellij.psi.templateLanguages.MultipleLangCommentProvider 实例源码

项目:intellij-ce-playground    文件:CommentByBlockCommentHandler.java   
@Nullable
public static Commenter getCommenter(final PsiFile file, final Editor editor,
                                     final Language lineStartLanguage, final Language lineEndLanguage) {

  final FileViewProvider viewProvider = file.getViewProvider();

  for (MultipleLangCommentProvider provider : MultipleLangCommentProvider.EP_NAME.getExtensions()) {
    if (provider.canProcess(file, viewProvider)) {
      return provider.getLineCommenter(file, editor, lineStartLanguage, lineEndLanguage);
    }
  }

  final Language fileLanguage = file.getLanguage();
  Language lang = lineStartLanguage == null || LanguageCommenters.INSTANCE.forLanguage(lineStartLanguage) == null ||
                  fileLanguage.getBaseLanguage() == lineStartLanguage // file language is a more specific dialect of the line language
                  ? fileLanguage
                  : lineStartLanguage;

  if (viewProvider instanceof TemplateLanguageFileViewProvider &&
      lang == ((TemplateLanguageFileViewProvider)viewProvider).getTemplateDataLanguage()) {
    lang = viewProvider.getBaseLanguage();
  }

  return LanguageCommenters.INSTANCE.forLanguage(lang);
}
项目:tools-idea    文件:CommentByBlockCommentHandler.java   
@Nullable
public static Commenter getCommenter(final PsiFile file, final Editor editor,
                                     final Language lineStartLanguage, final Language lineEndLanguage) {

  final FileViewProvider viewProvider = file.getViewProvider();

  for (MultipleLangCommentProvider provider : MultipleLangCommentProvider.EP_NAME.getExtensions()) {
    if (provider.canProcess(file, viewProvider)) {
      return provider.getLineCommenter(file, editor, lineStartLanguage, lineEndLanguage);
    }
  }

  final Language fileLanguage = file.getLanguage();
  Language lang = lineStartLanguage == null || LanguageCommenters.INSTANCE.forLanguage(lineStartLanguage) == null ||
                  fileLanguage.getBaseLanguage() == lineStartLanguage // file language is a more specific dialect of the line language
                  ? fileLanguage
                  : lineStartLanguage;

  if (viewProvider instanceof TemplateLanguageFileViewProvider &&
      lang == ((TemplateLanguageFileViewProvider)viewProvider).getTemplateDataLanguage()) {
    lang = viewProvider.getBaseLanguage();
  }

  return LanguageCommenters.INSTANCE.forLanguage(lang);
}
项目:consulo    文件:CommentByBlockCommentHandler.java   
@Nullable
public static Commenter getCommenter(final PsiFile file, final Editor editor, final Language lineStartLanguage, final Language lineEndLanguage) {

  final FileViewProvider viewProvider = file.getViewProvider();

  for (MultipleLangCommentProvider provider : MultipleLangCommentProvider.EP_NAME.getExtensions()) {
    if (provider.canProcess(file, viewProvider)) {
      return provider.getLineCommenter(file, editor, lineStartLanguage, lineEndLanguage);
    }
  }

  final Language fileLanguage = file.getLanguage();
  Language lang = lineStartLanguage == null || LanguageCommenters.INSTANCE.forLanguage(lineStartLanguage) == null || fileLanguage.getBaseLanguage() == lineStartLanguage
                  // file language is a more specific dialect of the line language
                  ? fileLanguage
                  : lineStartLanguage;

  if (viewProvider instanceof TemplateLanguageFileViewProvider && lang == ((TemplateLanguageFileViewProvider)viewProvider).getTemplateDataLanguage()) {
    lang = viewProvider.getBaseLanguage();
  }

  return LanguageCommenters.INSTANCE.forLanguage(lang);
}