Java源码示例:com.intellij.formatting.CustomFormattingModelBuilder

示例1
@Nullable
public FormattingModelBuilder forContext(@Nonnull Language language, @Nonnull PsiElement context) {
  for (LanguageFormattingRestriction each : LanguageFormattingRestriction.EXTENSION.getExtensionList()) {
    if (!each.isFormatterAllowed(context)) return null;
  }
  for (FormattingModelBuilder builder : allForLanguage(language)) {
    if (builder instanceof CustomFormattingModelBuilder) {
      final CustomFormattingModelBuilder custom = (CustomFormattingModelBuilder)builder;
      if (custom.isEngagedToFormat(context)) return builder;
    }
  }
  return forLanguage(language);
}