• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Indent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: add

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public Indent add(Indent indent) {
  IndentImpl indent1 = (IndentImpl)indent;
  return new IndentImpl(mySettings, myIndentLevel + indent1.myIndentLevel, mySpaceCount + indent1.mySpaceCount, myFileType);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:IndentImpl.java


示例17: subtract

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public Indent subtract(Indent indent) {
  IndentImpl indent1 = (IndentImpl)indent;
  return new IndentImpl(mySettings, myIndentLevel - indent1.myIndentLevel, mySpaceCount - indent1.mySpaceCount, myFileType);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:IndentImpl.java


示例18: getIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public Indent getIndent(String text, FileType fileType) {
  return delegate.getIndent(text, fileType);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:5,代码来源:DelegatingCodeStyleManager.java


示例19: fillIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public String fillIndent(Indent indent, FileType fileType) {
  return delegate.fillIndent(indent, fileType);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:5,代码来源:DelegatingCodeStyleManager.java


示例20: zeroIndent

import com.intellij.psi.codeStyle.Indent; //导入依赖的package包/类
@Override
public Indent zeroIndent() {
  return delegate.zeroIndent();
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:5,代码来源:DelegatingCodeStyleManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VmStateHistoryEntry类代码示例发布时间:2022-05-22
下一篇:
Java Pipe类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap