类com.intellij.psi.codeStyle.CustomCodeStyleSettings源码实例Demo

下面列出了怎么用com.intellij.psi.codeStyle.CustomCodeStyleSettings的API类实例代码及写法,或者点击链接到github查看源代码。


public FieldOption(@Nullable Class<? extends CustomCodeStyleSettings> clazz,
                   @Nonnull String fieldName,
                   @Nonnull String title,
                   @Nullable String groupName,
                   @Nullable OptionAnchor anchor,
                   @Nullable String anchorFiledName) {
  super(fieldName, title, groupName, anchor, anchorFiledName);
  this.clazz = clazz;

  try {
    Class styleSettingsClass = clazz == null ? CommonCodeStyleSettings.class : clazz;
    this.field = styleSettingsClass.getField(fieldName);
  }
  catch (NoSuchFieldException e) {
    LOG.error(e);
  }
}
 

public IntOption(Class<? extends CustomCodeStyleSettings> clazz,
                 @Nonnull String fieldName,
                 @Nonnull String title,
                 @Nullable String groupName,
                 @Nullable OptionAnchor anchor,
                 @Nullable String anchorFiledName,
                 int minValue,
                 int maxValue,
                 int defaultValue,
                 @Nullable Function<Integer, String> defaultValueRenderer) {
  super(clazz, fieldName, title, groupName, anchor, anchorFiledName);
  myMinValue = minValue;
  myMaxValue = maxValue;
  myDefaultValue = defaultValue;
  myDefaultValueRenderer = defaultValueRenderer;
}
 

@Override
public void showCustomOption(Class<? extends CustomCodeStyleSettings> settingsClass,
                             String fieldName,
                             String title,
                             String groupName,
                             @Nullable OptionAnchor anchor,
                             @Nullable String anchorFieldName,
                             Object... options) {
  if (myIsFirstUpdate) {
    myCustomOptions.putValue(groupName, Trinity.create(settingsClass, fieldName, title));
  }

  for (IntOption option : myOptions) {
    if (option.myTarget.getName().equals(fieldName)) {
      option.myIntField.setEnabled(true);
    }
  }
}
 

@Override
public void showCustomOption(Class<? extends CustomCodeStyleSettings> settingsClass,
                             String fieldName,
                             String title,
                             @Nullable String groupName,
                             @Nullable OptionAnchor anchor,
                             @Nullable String anchorFieldName,
                             Object... options) {
  if (isFirstUpdate) {
    myCustomOptions.putValue(groupName, new CustomBooleanOptionInfo(settingsClass, fieldName, title, groupName, anchor, anchorFieldName));
  }
  enableOption(fieldName);
}
 

private CustomBooleanOptionInfo(@Nonnull Class<? extends CustomCodeStyleSettings> settingClass,
                                @Nonnull String fieldName,
                                @Nonnull String title,
                                @Nullable String groupName,
                                @Nullable OptionAnchor anchor,
                                @Nullable String anchorFieldName) {
  this.settingClass = settingClass;
  this.fieldName = fieldName;
  this.title = title;
  this.groupName = groupName;
  this.anchor = anchor;
  this.anchorFieldName = anchorFieldName;
}
 

@Override
public void setValue(CodeStyleSettings settings, Boolean aBoolean) {
  final CustomCodeStyleSettings customSettings = settings.getCustomSettings(mySettingsClass);
  try {
    field.set(customSettings, aBoolean);
  }
  catch (Throwable e) {
    LOG.error("Field: " + field, e);
  }
}
 

@Override
public boolean getValue(CodeStyleSettings settings) throws IllegalAccessException {
  try {
    final CustomCodeStyleSettings customSettings = settings.getCustomSettings(mySettingsClass);
    return field.getBoolean(customSettings);
  }
  catch (Throwable e) {
    LOG.error("Field: " + field, e);
    return false;
  }
}
 

@Override
public void showCustomOption(Class<? extends CustomCodeStyleSettings> settingsClass,
                             String fieldName,
                             String title,
                             String groupName,
                             @Nullable OptionAnchor anchor,
                             @Nullable String anchorFieldName,
                             Object... options) {
  if (isFirstUpdate) {
    Option option;
    if (options.length == 2) {
      option = new SelectionOption(settingsClass, fieldName, title, groupName, anchor, anchorFieldName, (String[])options[0], (int[])options[1]);
    }
    else {
      option = new BooleanOption(settingsClass, fieldName, title, groupName, anchor, anchorFieldName);
    }
    myCustomOptions.add(option);
    option.setEnabled(true);
  }
  else {
    for (Option each : myCustomOptions) {
      if (each instanceof FieldOption && ((FieldOption)each).clazz == settingsClass && each.getOptionName().equals(fieldName)) {
        each.setEnabled(true);
      }
    }
  }
}
 

private BooleanOption(Class<? extends CustomCodeStyleSettings> clazz,
                      @Nonnull String fieldName,
                      @Nonnull String title,
                      @Nullable String groupName,
                      @Nullable OptionAnchor anchor,
                      @Nullable String anchorFiledName) {
  super(clazz, fieldName, title, groupName, anchor, anchorFiledName);
}
 

public SelectionOption(Class<? extends CustomCodeStyleSettings> clazz,
                       @Nonnull String fieldName,
                       @Nonnull String title,
                       @Nullable String groupName,
                       @Nullable OptionAnchor anchor,
                       @Nullable String anchorFiledName,
                       @Nonnull String[] options,
                       @Nonnull int[] values) {
  super(clazz, fieldName, title, groupName, anchor, anchorFiledName);
  this.options = options;
  this.values = values;
}
 

@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
    return new FluidCodeStyleSettings(settings);
}
 

@Nullable
@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
    return new FusionCodeStyleSettings(settings);
}
 

@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
    return new ProtoCodeStyleSettings(settings);
}
 

@Nullable
@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
    return new CypherCodeStyleSettings(settings);
}
 

@Nullable
@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
  return new BuildCodeStyleSettings(settings);
}
 

@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
  return new BuckCodeStyleSettings(settings);
}
 

@Nullable
@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
    return new LatexCodeStyleSettings(settings);
}
 

@Nullable
@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
	return new GLSLCodeStyleSettings(settings);
}
 

@Nullable
@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings)
{
	return new CSharpCodeGenerationSettings(settings);
}
 

@Nullable
@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings)
{
	return new CSharpCodeStyleSettings(settings);
}
 

@Nullable
@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
  return new HaxeCodeStyleSettings(settings);
}
 

@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
    return new XQueryCodeStyleSettings(settings);
}
 

@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
  return new BuckCodeStyleSettings(settings);
}
 
源代码24 项目: consulo   文件: CodeStyleBean.java

@Nonnull
protected final <T extends CustomCodeStyleSettings> T getCustomSettings(@Nonnull Class<T> settingsClass) {
  return myRootSettings.getCustomSettings(settingsClass);
}
 

@Override
public void showCustomOption(Class<? extends CustomCodeStyleSettings> settingsClass, String fieldName, String title, String groupName, Object... options) {
  showCustomOption(settingsClass, fieldName, title, groupName, null, null, options);
}
 

@Override
public void showCustomOption(Class<? extends CustomCodeStyleSettings> settingsClass, String fieldName, String title, String groupName, Object... options) {
  showCustomOption(settingsClass, fieldName, title, groupName, null, null, options);
}
 
源代码27 项目: consulo   文件: CodeStyleBlankLinesPanel.java

private void initCustomOptions(OptionGroup optionGroup, String groupName) {
  for (Trinity<Class<? extends CustomCodeStyleSettings>, String, String> each : myCustomOptions.get(groupName)) {
    doCreateOption(optionGroup, each.third, new IntOption(each.third, each.first, each.second), each.second);
  }
}
 
源代码28 项目: consulo   文件: CodeStyleBlankLinesPanel.java

@Override
public void showCustomOption(Class<? extends CustomCodeStyleSettings> settingsClass, String fieldName, String title, String groupName, Object... options) {
  showCustomOption(settingsClass, fieldName, title, groupName, null, null, options);
}
 
源代码29 项目: consulo   文件: CodeStyleBlankLinesPanel.java

private IntOption(@Nonnull String title, Class<? extends CustomCodeStyleSettings> targetClass, String fieldName) {
  this(title, targetClass, fieldName, false);
  myTargetClass = targetClass;
}
 
 类所在包
 同包方法