当前位置: 首页>>代码示例>>Java>>正文


Java CodeStyleSettings.setDefaultRightMargin方法代码示例

本文整理汇总了Java中com.intellij.psi.codeStyle.CodeStyleSettings.setDefaultRightMargin方法的典型用法代码示例。如果您正苦于以下问题:Java CodeStyleSettings.setDefaultRightMargin方法的具体用法?Java CodeStyleSettings.setDefaultRightMargin怎么用?Java CodeStyleSettings.setDefaultRightMargin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.codeStyle.CodeStyleSettings的用法示例。


在下文中一共展示了CodeStyleSettings.setDefaultRightMargin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCommentAfterDeclaration

import com.intellij.psi.codeStyle.CodeStyleSettings; //导入方法依赖的package包/类
public void testCommentAfterDeclaration() throws Exception {
  CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject());
  CommonCodeStyleSettings javaSettings = codeStyleSettings.getCommonSettings(JavaLanguage.INSTANCE);

  int oldMargin = codeStyleSettings.getDefaultRightMargin();
  int oldWrap = javaSettings.ASSIGNMENT_WRAP;

  try {
    codeStyleSettings.setDefaultRightMargin(20);
    javaSettings.ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
    doMethodTest(
      "int i=0; //comment comment",
      "int i =\n" +
      "        0; //comment comment"
    );

  }
  finally {
    codeStyleSettings.setDefaultRightMargin(oldMargin);
    javaSettings.ASSIGNMENT_WRAP = oldWrap;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JavaFormatterTest.java

示例2: testLastLineIndent

import com.intellij.psi.codeStyle.CodeStyleSettings; //导入方法依赖的package包/类
public void testLastLineIndent() throws Exception{
  final String initialText = "a\n";
  final TestFormattingModel model = new TestFormattingModel(initialText);

  model.setRootBlock(new FormattingModelXmlReader(model).readTestBlock("lineIndent"));
  final CommonCodeStyleSettings.IndentOptions indentOptions = new CommonCodeStyleSettings.IndentOptions();
  indentOptions.CONTINUATION_INDENT_SIZE = 8;
  indentOptions.INDENT_SIZE = 4;
  indentOptions.LABEL_INDENT_SIZE = 1;
  final CodeStyleSettings settings = new CodeStyleSettings(false);
  settings.setDefaultRightMargin(myRightMargin);
  try {
    FormatterEx.getInstanceEx().adjustLineIndent(model, settings, indentOptions, initialText.length() - 1, new TextRange(0, initialText.length()));
  }
  catch (IncorrectOperationException e) {
    fail();
  }

  assertEquals("a\n    ", FormatterImpl.getText(model));

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GeneralCodeFormatterTest.java

示例3: doTest

import com.intellij.psi.codeStyle.CodeStyleSettings; //导入方法依赖的package包/类
private void doTest(final String formattingModelName,
                    final String initial,
                    final String expected) throws IOException, JDOMException {
  final TestFormattingModel model = new TestFormattingModel(initial);

  model.setRootBlock(new FormattingModelXmlReader(model).readTestBlock(formattingModelName));
  final CommonCodeStyleSettings.IndentOptions indentOptions = new CommonCodeStyleSettings.IndentOptions();
  indentOptions.CONTINUATION_INDENT_SIZE = 8;
  indentOptions.INDENT_SIZE = 4;
  indentOptions.LABEL_INDENT_SIZE = 1;
  final CodeStyleSettings settings = new CodeStyleSettings(false);
  settings.setDefaultRightMargin(myRightMargin);
  try {
    FormatterEx.getInstanceEx().format(model, settings, indentOptions, indentOptions, null);
  }
  catch (IncorrectOperationException e) {
    fail();
  }

  assertEquals(expected, FormatterImpl.getText(model));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GeneralCodeFormatterTest.java

示例4: apply

import com.intellij.psi.codeStyle.CodeStyleSettings; //导入方法依赖的package包/类
@Override
public void apply(CodeStyleSettings settings) {
  settings.LINE_SEPARATOR = getSelectedLineSeparator();

  settings.setDefaultRightMargin(getRightMargin());
  settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = myCbWrapWhenTypingReachesRightMargin.isSelected();

  settings.FORMATTER_TAGS_ENABLED = myEnableFormatterTags.isSelected();
  settings.FORMATTER_TAGS_ACCEPT_REGEXP = myAcceptRegularExpressionsCheckBox.isSelected();

  settings.FORMATTER_OFF_TAG = getTagText(myFormatterOffTagField, settings.FORMATTER_OFF_TAG);
  settings.setFormatterOffPattern(compilePattern(settings, myFormatterOffTagField, settings.FORMATTER_OFF_TAG));

  settings.FORMATTER_ON_TAG = getTagText(myFormatterOnTagField, settings.FORMATTER_ON_TAG);
  settings.setFormatterOnPattern(compilePattern(settings, myFormatterOnTagField, settings.FORMATTER_ON_TAG));

  settings.AUTODETECT_INDENTS = myAutodetectIndentsBox.isSelected();
  if (myShowDetectedIndentNotification.isEnabled()) {
    FileIndentOptionsProvider.setShowNotification(myShowDetectedIndentNotification.isSelected());
  }

  for (GeneralCodeStyleOptionsProvider option : myAdditionalOptions) {
    option.apply(settings);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GeneralCodeStylePanel.java

示例5: modify

import com.intellij.psi.codeStyle.CodeStyleSettings; //导入方法依赖的package包/类
public static void modify(CodeStyleSettings settings) {
  // Use Android XML formatter by default
  AndroidXmlCodeStyleSettings.getInstance(settings).USE_CUSTOM_SETTINGS = true;

  // XML:
  // Copy Android code style
  AndroidXmlPredefinedCodeStyle xmlStyle = new AndroidXmlPredefinedCodeStyle();
  xmlStyle.apply(settings);

  // Java:
  // Set Import order
  settings.IMPORT_LAYOUT_TABLE.copyFrom(getAndroidImportOrder());

  // Don't use wildcard imports
  settings.PACKAGES_TO_USE_IMPORT_ON_DEMAND.copyFrom(new PackageEntryTable());
  settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND = 99; // Class count to use import with "*"
  settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND = 99; // Name count to use static import with "*"

  // set margin to 100 columns
  settings.setDefaultRightMargin(100);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:AndroidCodeStyleSettingsModifier.java

示例6: testWrongWrapping

import com.intellij.psi.codeStyle.CodeStyleSettings; //导入方法依赖的package包/类
public void testWrongWrapping() throws Exception{
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
  settings.setDefaultRightMargin(80);
  settings.CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
  settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
  doTest();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:JoinLinesTest.java

示例7: testSubsequentJoiningAndUnexpectedTextRemoval

import com.intellij.psi.codeStyle.CodeStyleSettings; //导入方法依赖的package包/类
public void testSubsequentJoiningAndUnexpectedTextRemoval() throws Exception {
  // Inspired by IDEA-65342
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
  settings.setDefaultRightMargin(50);
  settings.getCommonSettings(JavaLanguage.INSTANCE).CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
  doTest(2);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:JoinLinesTest.java

示例8: testDontKeepLineBreaksInText

import com.intellij.psi.codeStyle.CodeStyleSettings; //导入方法依赖的package包/类
public void testDontKeepLineBreaksInText() throws Throwable {
  final CodeStyleSettings settings = getSettings();
  final XmlCodeStyleSettings xmlSettings = settings.getCustomSettings(XmlCodeStyleSettings.class);
  settings.setDefaultRightMargin(15);

  settings.HTML_KEEP_LINE_BREAKS_IN_TEXT = false;
  xmlSettings.XML_KEEP_LINE_BREAKS_IN_TEXT = false;
  doTextTest("<tag>aaa\nbbb\nccc\nddd\n</tag>", "<tag>aaa bbb\n    ccc ddd\n</tag>");

  settings.HTML_TEXT_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
  xmlSettings.XML_TEXT_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
  doTextTest("<tag>aaa\nbbb\nccc\nddd\n</tag>", "<tag>aaa bbb ccc ddd\n</tag>");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:XmlFormatterTestCase.java


注:本文中的com.intellij.psi.codeStyle.CodeStyleSettings.setDefaultRightMargin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。