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


Java Indent类代码示例

本文整理汇总了Java中com.intellij.psi.codeStyle.Indent的典型用法代码示例。如果您正苦于以下问题:Java Indent类的具体用法?Java Indent怎么用?Java Indent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: computeMinIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
private Indent computeMinIndent(Editor editor, PsiFile psiFile, int line1, int line2, FileType fileType) {
  Document document = editor.getDocument();
  Indent minIndent = CommentUtil.getMinLineIndent(myProject, document, line1, line2, fileType);
  if (line1 > 0) {
    int commentOffset = getCommentStart(editor, psiFile, line1 - 1);
    if (commentOffset >= 0) {
      int lineStart = document.getLineStartOffset(line1 - 1);
      String space = document.getCharsSequence().subSequence(lineStart, commentOffset).toString();
      Indent indent = myCodeStyleManager.getIndent(space, fileType);
      minIndent = minIndent != null ? indent.min(minIndent) : indent;
    }
  }
  if (minIndent == null) {
    minIndent = myCodeStyleManager.zeroIndent();
  }
  return minIndent;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:CommentByLineCommentHandler.java

示例2: getMinLineIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
public static Indent getMinLineIndent(Project project, Document document, int line1, int line2, FileType fileType) {
  CharSequence chars = document.getCharsSequence();
  CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
  Indent minIndent = null;
  for (int line = line1; line <= line2; line++) {
    int lineStart = document.getLineStartOffset(line);
    int textStart = CharArrayUtil.shiftForward(chars, lineStart, " \t");
    if (textStart >= document.getTextLength()) {
      textStart = document.getTextLength();
    }
    else {
      char c = chars.charAt(textStart);
      if (c == '\n' || c == '\r') continue; // empty line
    }
    String space = chars.subSequence(lineStart, textStart).toString();
    Indent indent = codeStyleManager.getIndent(space, fileType);
    minIndent = minIndent != null ? indent.min(minIndent) : indent;
  }
  if (minIndent == null && line1 == line2 && line1 < document.getLineCount() - 1) {
    return getMinLineIndent(project, document, line1 + 1, line1 + 1, fileType);
  }
  //if (minIndent == Integer.MAX_VALUE){
  //  minIndent = 0;
  //}
  return minIndent;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:CommentUtil.java

示例3: fillIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public String fillIndent(Indent indent, FileType fileType) {
  IndentImpl indent1 = (IndentImpl)indent;
  int indentLevel = indent1.getIndentLevel();
  int spaceCount = indent1.getSpaceCount();
  if (indentLevel < 0) {
    spaceCount += indentLevel * getSettings().getIndentSize(fileType);
    indentLevel = 0;
    if (spaceCount < 0) {
      spaceCount = 0;
    }
  }
  else {
    if (spaceCount < 0) {
      int v = (-spaceCount + getSettings().getIndentSize(fileType) - 1) / getSettings().getIndentSize(fileType);
      indentLevel -= v;
      spaceCount += v * getSettings().getIndentSize(fileType);
      if (indentLevel < 0) {
        indentLevel = 0;
      }
    }
  }
  return IndentHelperImpl.fillIndent(myProject, fileType, indentLevel * IndentHelperImpl.INDENT_FACTOR + spaceCount);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CodeStyleManagerImpl.java

示例4: computeMinIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
private Indent computeMinIndent(int line1, int line2, CharSequence chars, CodeStyleManager codeStyleManager, FileType fileType) {
  Indent minIndent = CommentUtil.getMinLineIndent(myProject, myDocument, line1, line2, fileType);
  if (line1 > 0) {
    int commentOffset = getCommentStart(line1 - 1);
    if (commentOffset >= 0) {
      int lineStart = myDocument.getLineStartOffset(line1 - 1);
      String space = chars.subSequence(lineStart, commentOffset).toString();
      Indent indent = codeStyleManager.getIndent(space, fileType);
      minIndent = minIndent != null ? indent.min(minIndent) : indent;
    }
  }
  if (minIndent == null) {
    minIndent = codeStyleManager.zeroIndent();
  }
  return minIndent;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:CommentByLineCommentHandler.java

示例5: doIndentCommenting

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
private void doIndentCommenting(final Block block) {
  final Document document = block.editor.getDocument();
  final CharSequence chars = document.getCharsSequence();
  final FileType fileType = block.psiFile.getFileType();
  final Indent minIndent = computeMinIndent(block.editor, block.psiFile, block.startLine, block.endLine, fileType);

  DocumentUtil.executeInBulk(
    document, block.endLine - block.startLine > Registry.intValue("comment.by.line.bulk.lines.trigger"), new Runnable() {
      @Override
      public void run() {
        for (int line = block.endLine; line >= block.startLine; line--) {
          int lineStart = document.getLineStartOffset(line);
          int offset = lineStart;
          final StringBuilder buffer = new StringBuilder();
          while (true) {
            String space = buffer.toString();
            Indent indent = myCodeStyleManager.getIndent(space, fileType);
            if (indent.isGreaterThan(minIndent) || indent.equals(minIndent)) break;
            char c = chars.charAt(offset);
            if (c != ' ' && c != '\t') {
              String newSpace = myCodeStyleManager.fillIndent(minIndent, fileType);
              document.replaceString(lineStart, offset, newSpace);
              offset = lineStart + newSpace.length();
              break;
            }
            buffer.append(c);
            offset++;
          }
          commentLine(block, line, offset);
        }
      }
    });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:CommentByLineCommentHandler.java

示例6: getIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public Indent getIndent(String text, FileType fileType) {
  int indent = IndentHelperImpl.getIndent(myProject, fileType, text, true);
  int indenLevel = indent / IndentHelperImpl.INDENT_FACTOR;
  int spaceCount = indent - indenLevel * IndentHelperImpl.INDENT_FACTOR;
  return new IndentImpl(getSettings(), indenLevel, spaceCount, fileType);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:CodeStyleManagerImpl.java

示例7: doIndentCommenting

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
private void doIndentCommenting(final Commenter commenter) {
  final CharSequence chars = myDocument.getCharsSequence();
  final FileType fileType = myFile.getFileType();
  final Indent minIndent = computeMinIndent(myStartLine, myEndLine, chars, myCodeStyleManager, fileType);

  DocumentUtil.executeInBulk(
    myDocument, myEndLine - myStartLine > Registry.intValue("comment.by.line.bulk.lines.trigger"), new Runnable() {
    @Override
    public void run() {
      for (int line = myEndLine; line >= myStartLine; line--) {
        int lineStart = myDocument.getLineStartOffset(line);
        int offset = lineStart;
        final StringBuilder buffer = new StringBuilder();
        while (true) {
          String space = buffer.toString();
          Indent indent = myCodeStyleManager.getIndent(space, fileType);
          if (indent.isGreaterThan(minIndent) || indent.equals(minIndent)) break;
          char c = chars.charAt(offset);
          if (c != ' ' && c != '\t') {
            String newSpace = myCodeStyleManager.fillIndent(minIndent, fileType);
            myDocument.replaceString(lineStart, offset, newSpace);
            offset = lineStart + newSpace.length();
            break;
          }
          buffer.append(c);
          offset++;
        }
        commentLine(line, offset, commenter);
      }
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:CommentByLineCommentHandler.java

示例8: getIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public Indent getIndent(String text, FileType fileType) {
  int indent = IndentHelperImpl.getIndent(myProject, fileType, text, true);
  int indentLevel = indent / IndentHelperImpl.INDENT_FACTOR;
  int spaceCount = indent - indentLevel * IndentHelperImpl.INDENT_FACTOR;
  return new IndentImpl(getSettings(), indentLevel, spaceCount, fileType);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:8,代码来源:CodeStyleManagerImpl.java

示例9: getIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public Indent getIndent(String text, FileType fileType) {
  throw new UnsupportedOperationException("com.intellij.codeInsight.actions.MockCodeStyleManager.getIndent(...)");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MockCodeStyleManager.java

示例10: fillIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public String fillIndent(Indent indent, FileType fileType) {
  throw new UnsupportedOperationException("com.intellij.codeInsight.actions.MockCodeStyleManager.fillIndent(...)");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MockCodeStyleManager.java

示例11: zeroIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public Indent zeroIndent() {
  throw new UnsupportedOperationException("com.intellij.codeInsight.actions.MockCodeStyleManager.zeroIndent(...)");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MockCodeStyleManager.java

示例12: zeroIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public Indent zeroIndent() {
  return new IndentImpl(getSettings(), 0, 0, null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:CodeStyleManagerImpl.java

示例13: isGreaterThan

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public boolean isGreaterThan(Indent indent) {
  return getSize() > ((IndentImpl)indent).getSize();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:IndentImpl.java

示例14: min

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public Indent min(Indent anotherIndent) {
  return isGreaterThan(anotherIndent) ? anotherIndent : this;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:IndentImpl.java

示例15: max

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public Indent max(Indent anotherIndent) {
  return isGreaterThan(anotherIndent) ? this : anotherIndent;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:IndentImpl.java


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