本文整理汇总了Java中com.intellij.psi.codeStyle.Indent.min方法的典型用法代码示例。如果您正苦于以下问题:Java Indent.min方法的具体用法?Java Indent.min怎么用?Java Indent.min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.codeStyle.Indent
的用法示例。
在下文中一共展示了Indent.min方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: 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;
}