當前位置: 首頁>>代碼示例>>Java>>正文


Java CodeStyleSettings.useTabCharacter方法代碼示例

本文整理匯總了Java中com.intellij.psi.codeStyle.CodeStyleSettings.useTabCharacter方法的典型用法代碼示例。如果您正苦於以下問題:Java CodeStyleSettings.useTabCharacter方法的具體用法?Java CodeStyleSettings.useTabCharacter怎麽用?Java CodeStyleSettings.useTabCharacter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.codeStyle.CodeStyleSettings的用法示例。


在下文中一共展示了CodeStyleSettings.useTabCharacter方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testUnwrapCodeBlock1

import com.intellij.psi.codeStyle.CodeStyleSettings; //導入方法依賴的package包/類
public void testUnwrapCodeBlock1() throws Exception {
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
  boolean use_tab_character = settings.useTabCharacter(null);
  boolean smart_tabs = settings.isSmartTabs(null);
  int old = settings.IF_BRACE_FORCE;
  try {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
    settings.getCommonSettings(JavaLanguage.INSTANCE).IF_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_IF_MULTILINE;
    doTest();
  } finally {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = use_tab_character;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = smart_tabs;
    settings.getCommonSettings(JavaLanguage.INSTANCE).IF_BRACE_FORCE = old;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:JoinLinesTest.java

示例2: testUnwrapCodeBlock2

import com.intellij.psi.codeStyle.CodeStyleSettings; //導入方法依賴的package包/類
public void testUnwrapCodeBlock2() throws Exception {
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
  boolean use_tab_character = settings.useTabCharacter(null);
  boolean smart_tabs = settings.isSmartTabs(null);
  int old = settings.IF_BRACE_FORCE;
  try {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
    settings.getCommonSettings(JavaLanguage.INSTANCE).IF_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
    doTest();
  } finally {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = use_tab_character;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = smart_tabs;
    settings.getCommonSettings(JavaLanguage.INSTANCE).IF_BRACE_FORCE = old;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:JoinLinesTest.java

示例3: testSCR3493

import com.intellij.psi.codeStyle.CodeStyleSettings; //導入方法依賴的package包/類
public void testSCR3493() throws Exception {
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
  boolean use_tab_character = settings.useTabCharacter(null);
  boolean smart_tabs = settings.isSmartTabs(null);
  try {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
    doTest();
  } finally {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = use_tab_character;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = smart_tabs;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:JoinLinesTest.java

示例4: testSCR3493a

import com.intellij.psi.codeStyle.CodeStyleSettings; //導入方法依賴的package包/類
public void testSCR3493a() throws Exception {
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
  boolean use_tab_character = settings.useTabCharacter(null);
  boolean smart_tabs = settings.isSmartTabs(null);
  try {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
    doTest();
  } finally {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = use_tab_character;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = smart_tabs;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:JoinLinesTest.java

示例5: testSCR3493b

import com.intellij.psi.codeStyle.CodeStyleSettings; //導入方法依賴的package包/類
public void testSCR3493b() throws Exception {
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
  boolean use_tab_character = settings.useTabCharacter(null);
  boolean smart_tabs = settings.isSmartTabs(null);
  try {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
    doTest();
  } finally {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = use_tab_character;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = smart_tabs;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:JoinLinesTest.java

示例6: testSCR3493c

import com.intellij.psi.codeStyle.CodeStyleSettings; //導入方法依賴的package包/類
public void testSCR3493c() throws Exception {
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
  boolean use_tab_character = settings.useTabCharacter(null);
  boolean smart_tabs = settings.isSmartTabs(null);
  try {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
    doTest();
  } finally {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = use_tab_character;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = smart_tabs;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:JoinLinesTest.java

示例7: testSCR3493d

import com.intellij.psi.codeStyle.CodeStyleSettings; //導入方法依賴的package包/類
public void testSCR3493d() throws Exception {
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
  boolean use_tab_character = settings.useTabCharacter(null);
  boolean smart_tabs = settings.isSmartTabs(null);
  try {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
    doTest();
  } finally {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = use_tab_character;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = smart_tabs;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:JoinLinesTest.java

示例8: testSCR3493e

import com.intellij.psi.codeStyle.CodeStyleSettings; //導入方法依賴的package包/類
public void testSCR3493e() throws Exception {
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
  boolean use_tab_character = settings.useTabCharacter(null);
  boolean smart_tabs = settings.isSmartTabs(null);
  try {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
    doTest();
  } finally {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = use_tab_character;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = smart_tabs;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:JoinLinesTest.java

示例9: fillIndent

import com.intellij.psi.codeStyle.CodeStyleSettings; //導入方法依賴的package包/類
public static String fillIndent(Project project, FileType fileType, int indent) {
  final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);
  int indentLevel = (indent + INDENT_FACTOR / 2) / INDENT_FACTOR;
  int spaceCount = indent - indentLevel * INDENT_FACTOR;
  int indentLevelSize = indentLevel * settings.getIndentSize(fileType);
  int totalSize = indentLevelSize + spaceCount;

  StringBuilder buffer = new StringBuilder();
  if (settings.useTabCharacter(fileType)) {
    if (settings.isSmartTabs(fileType)) {
      int tabCount = indentLevelSize / settings.getTabSize(fileType);
      int leftSpaces = indentLevelSize - tabCount * settings.getTabSize(fileType);
      for (int i = 0; i < tabCount; i++) {
        buffer.append('\t');
      }
      for (int i = 0; i < leftSpaces + spaceCount; i++) {
        buffer.append(' ');
      }
    }
    else {
      int size = totalSize;
      while (size > 0) {
        if (size >= settings.getTabSize(fileType)) {
          buffer.append('\t');
          size -= settings.getTabSize(fileType);
        }
        else {
          buffer.append(' ');
          size--;
        }
      }
    }
  }
  else {
    for (int i = 0; i < totalSize; i++) {
      buffer.append(' ');
    }
  }

  return buffer.toString();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:42,代碼來源:IndentHelperImpl.java

示例10: ignoreDueToSettings

import com.intellij.psi.codeStyle.CodeStyleSettings; //導入方法依賴的package包/類
private static boolean ignoreDueToSettings(Project project, Problem problem, PsiElement element) {
  final EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
  if (!editorSettings.getStripTrailingSpaces().equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE)) {
    // ignore trailing spaces errors if they're going to disappear after save
    if (problem.myCode.equals("W291") || problem.myCode.equals("W293")) {
      return true;
    }
  }
  
  final CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(project);
  final CommonCodeStyleSettings commonSettings = codeStyleSettings.getCommonSettings(PythonLanguage.getInstance());
  final PyCodeStyleSettings pySettings = codeStyleSettings.getCustomSettings(PyCodeStyleSettings.class);
  // E303 too many blank lines (num)
  if (problem.myCode.equals("E303") && element instanceof PsiWhiteSpace) {
    final Matcher matcher = E303_LINE_COUNT_PATTERN.matcher(problem.myDescription);
    if (matcher.matches()) {
      final int reportedBlanks = Integer.parseInt(matcher.group(1));
      final PsiElement nonWhitespaceAfter = PyPsiUtils.getNextNonWhitespaceSibling(element);
      final PsiElement nonWhitespaceBefore = PyPsiUtils.getPrevNonWhitespaceSibling(element);
      final boolean classNearby = nonWhitespaceBefore instanceof PyClass || nonWhitespaceAfter instanceof PyClass;
      final boolean functionNearby = nonWhitespaceBefore instanceof PyFunction || nonWhitespaceAfter instanceof PyFunction;
      if (functionNearby || classNearby) {
        if (PyUtil.isTopLevel(element)) {
          if (reportedBlanks <= pySettings.BLANK_LINES_AROUND_TOP_LEVEL_CLASSES_FUNCTIONS) {
            return true;
          }
        }
        else {
          // Blanks around classes have priority over blanks around functions as defined in Python spacing builder
          if (classNearby && reportedBlanks <= commonSettings.BLANK_LINES_AROUND_CLASS ||
              functionNearby && reportedBlanks <= commonSettings.BLANK_LINES_AROUND_METHOD) {
            return true;
          }
        }
      }
    }
  }
  if (problem.myCode.equals("W191") && codeStyleSettings.useTabCharacter(PythonFileType.INSTANCE)) {
    return true;
  }
  // E251 unexpected spaces around keyword / parameter equals
  // Note that E222 (multiple spaces after operator) is not suppressed, though. 
  if (problem.myCode.equals("E251") &&
      (element.getParent() instanceof PyParameter && pySettings.SPACE_AROUND_EQ_IN_NAMED_PARAMETER ||
       element.getParent() instanceof PyKeywordArgument && pySettings.SPACE_AROUND_EQ_IN_KEYWORD_ARGUMENT)) {
    return true;
  }
    return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:50,代碼來源:Pep8ExternalAnnotator.java

示例11: preprocessOnPaste

import com.intellij.psi.codeStyle.CodeStyleSettings; //導入方法依賴的package包/類
@NotNull
@Override
public String preprocessOnPaste(Project project,
                                PsiFile file,
                                Editor editor,
                                String text,
                                RawText rawText) {
  if (!CodeInsightSettings.getInstance().INDENT_TO_CARET_ON_PASTE || file.getLanguage() != PythonLanguage.getInstance()) {
    return text;
  }
  final CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(project);
  final boolean useTabs = codeStyleSettings.useTabCharacter(PythonFileType.INSTANCE);
  final int indentSize = codeStyleSettings.getIndentSize(PythonFileType.INSTANCE);
  CharFilter NOT_INDENT_FILTER = new CharFilter() {
    public boolean accept(char ch) {
      return useTabs? ch != '\t' : ch != ' ';
    }
  };
  final String indentChar = useTabs ? "\t" : " ";

  final CaretModel caretModel = editor.getCaretModel();
  final SelectionModel selectionModel = editor.getSelectionModel();
  final Document document = editor.getDocument();
  final int caretOffset = selectionModel.getSelectionStart() != selectionModel.getSelectionEnd() ?
                          selectionModel.getSelectionStart() : caretModel.getOffset();
  final int lineNumber = document.getLineNumber(caretOffset);
  final int lineStartOffset = getLineStartSafeOffset(document, lineNumber);
  final int lineEndOffset = document.getLineEndOffset(lineNumber);

  final PsiElement element = file.findElementAt(caretOffset);
  if (PsiTreeUtil.getParentOfType(element, PyStringLiteralExpression.class) != null) return text;

  text = addLeadingSpaces(text, NOT_INDENT_FILTER, indentSize, indentChar);
  int firstLineIndent = StringUtil.findFirst(text, NOT_INDENT_FILTER);
  final String indentText = getIndentText(file, document, caretOffset, lineNumber, firstLineIndent);

  int toRemove = calculateIndentToRemove(text, NOT_INDENT_FILTER);

  final String toString = document.getText(TextRange.create(lineStartOffset, lineEndOffset));
  if (StringUtil.isEmptyOrSpaces(indentText) && isApplicable(file, text, caretOffset)) {
    caretModel.moveToOffset(lineStartOffset);

    if (StringUtil.isEmptyOrSpaces(toString)) {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          document.deleteString(lineStartOffset, lineEndOffset);
        }
      });
    }
    editor.getSelectionModel().setSelection(lineStartOffset, selectionModel.getSelectionEnd());
  }

  final List<String> strings = StringUtil.split(text, "\n", false);
  String newText = "";
  if (StringUtil.isEmptyOrSpaces(indentText)) {
    for (String s : strings) {
      newText += indentText + StringUtil.trimStart(s, StringUtil.repeat(indentChar, toRemove));
    }
  }
  else {
    newText = text;
  }

  if (addLinebreak(text, toString, useTabs) && selectionModel.getSelectionStart() == selectionModel.getSelectionEnd())
    newText += "\n";
  return newText;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:69,代碼來源:PythonCopyPasteProcessor.java


注:本文中的com.intellij.psi.codeStyle.CodeStyleSettings.useTabCharacter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。