本文整理汇总了Java中com.intellij.formatting.Spacing.createKeepingFirstColumnSpacing方法的典型用法代码示例。如果您正苦于以下问题:Java Spacing.createKeepingFirstColumnSpacing方法的具体用法?Java Spacing.createKeepingFirstColumnSpacing怎么用?Java Spacing.createKeepingFirstColumnSpacing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.formatting.Spacing
的用法示例。
在下文中一共展示了Spacing.createKeepingFirstColumnSpacing方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: manageComments
import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private boolean manageComments() {
if (mySettings.KEEP_FIRST_COLUMN_COMMENT && TokenSets.COMMENT_SET.contains(myType2)) {
if (!isAfterElementOrSemi(GroovyElementTypes.IMPORT_STATEMENT)) {
myResult = Spacing.createKeepingFirstColumnSpacing(0, Integer.MAX_VALUE, true, 1);
return true;
}
return false;
}
ASTNode prev = FormatterUtil.getPreviousNonWhitespaceLeaf(myChild2);
if (prev != null && prev.getElementType() == GroovyTokenTypes.mNLS) {
prev = FormatterUtil.getPreviousNonWhitespaceLeaf(prev);
}
if (prev != null && prev.getElementType() == GroovyTokenTypes.mSL_COMMENT) {
myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
return true;
}
return false;
}
示例2: manageComments
import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private boolean manageComments() {
if (mySettings.KEEP_FIRST_COLUMN_COMMENT && COMMENT_SET.contains(myType2)) {
if (myType1 != IMPORT_STATEMENT) {
myResult = Spacing.createKeepingFirstColumnSpacing(0, Integer.MAX_VALUE, true, 1);
}
return true;
}
ASTNode prev = FormatterUtil.getPreviousNonWhitespaceLeaf(myChild2);
if (prev != null && prev.getElementType() == mNLS) {
prev = FormatterUtil.getPreviousNonWhitespaceLeaf(prev);
}
if (prev != null && prev.getElementType() == mSL_COMMENT) {
myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
return true;
}
return false;
}
示例3: doInit
import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private void doInit() {
if (myChild1 == null || myChild2 == null) return;
PsiElement psi1 = myChild1.getPsi();
PsiElement psi2 = myChild2.getPsi();
if (psi1 == null || psi2 == null) return;
if (psi1.getLanguage() != LuaFileType.LUA_LANGUAGE ||
psi2.getLanguage() != LuaFileType.LUA_LANGUAGE) {
return;
}
if (myChild2 != null && mySettings.KEEP_FIRST_COLUMN_COMMENT && SpacingUtil.COMMENT_BIT_SET.contains(myChild2.getElementType())) {
myResult = Spacing.createKeepingFirstColumnSpacing(0, Integer.MAX_VALUE, true, 1);
return;
}
if (myChild1 != null && myChild2 != null && myChild1.getElementType() == NEWLINE) {
final ASTNode prev = SpacingUtil.getPrevElementType(myChild1);
if (prev != null && prev.getElementType() == SHORTCOMMENT) {
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
return;
}
}
if (myParent instanceof LuaPsiElement) {
((LuaPsiElement) myParent).accept(this);
}
}
示例4: doInit
import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private void doInit(ASTNode child, CommonCodeStyleSettings settings, JavaCodeStyleSettings javaSettings) {
init(child);
mySettings = settings;
myJavaSettings = javaSettings;
if (myChild1 == null) {
// Given node corresponds to the first document block.
if (FormatterUtil.isFormatterCalledExplicitly()) {
createSpaceInCode(false);
}
return;
}
final PsiElement myChild1Psi1 = myChild1.getPsi();
final PsiElement myChild1Psi2 = myChild2.getPsi();
if (myChild1Psi1 == null || myChild1Psi1.getLanguage() != JavaLanguage.INSTANCE ||
myChild1Psi2 == null || myChild1Psi2.getLanguage() != JavaLanguage.INSTANCE) {
return;
}
if (myChild2 != null && StdTokenSets.COMMENT_BIT_SET.contains(myChild2.getElementType())) {
if (myChild2.getElementType() == JavaTokenType.C_STYLE_COMMENT) {
myResult = Spacing.getReadOnlySpacing();
}
else if (mySettings.KEEP_FIRST_COLUMN_COMMENT) {
myResult = Spacing.createKeepingFirstColumnSpacing(0, Integer.MAX_VALUE, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else {
myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 0, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
}
else {
if (myParent != null) {
myParent.accept(this);
if (myResult == null) {
final ASTNode prev = getPrevElementType(myChild2);
if (prev != null && prev.getElementType() == JavaTokenType.END_OF_LINE_COMMENT) {
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else if (!canStickChildrenTogether(myChild1, myChild2)) {
myResult = Spacing.createSpacing(1, Integer.MIN_VALUE, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else if (myChild1.getElementType() == JavaTokenType.C_STYLE_COMMENT){
myResult = null;
}
else if (!shouldKeepSpace(myParent)){
myResult = Spacing.createSpacing(0, 0, 0, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
}
}
}
}
示例5: doInit
import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private void doInit(final ASTNode child, final CommonCodeStyleSettings settings) {
init(child);
mySettings = settings;
if (myChild1 == null) {
// Given node corresponds to the first document block.
if (FormatterUtil.isFormatterCalledExplicitly()) {
createSpaceInCode(false);
}
return;
}
final PsiElement myChild1Psi1 = myChild1.getPsi();
final PsiElement myChild1Psi2 = myChild2.getPsi();
if (myChild1Psi1 == null || myChild1Psi1.getLanguage() != JavaLanguage.INSTANCE ||
myChild1Psi2 == null || myChild1Psi2.getLanguage() != JavaLanguage.INSTANCE) {
return;
}
if (myChild2 != null && StdTokenSets.COMMENT_BIT_SET.contains(myChild2.getElementType())) {
if (myChild2.getElementType() == JavaTokenType.C_STYLE_COMMENT) {
myResult = Spacing.getReadOnlySpacing();
}
else if (mySettings.KEEP_FIRST_COLUMN_COMMENT) {
myResult = Spacing
.createKeepingFirstColumnSpacing(0, Integer.MAX_VALUE, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else {
myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 0, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
}
else {
if (myParent != null) {
myParent.accept(this);
if (myResult == null) {
final ASTNode prev = getPrevElementType(myChild2);
if (prev != null && prev.getElementType() == JavaTokenType.END_OF_LINE_COMMENT) {
myResult = Spacing
.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else if (!canStickChildrenTogether(myChild1, myChild2)) {
myResult = Spacing
.createSpacing(1, Integer.MIN_VALUE, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else if (myChild1.getElementType() == JavaTokenType.C_STYLE_COMMENT){
myResult = null;
}
else if (!shouldKeepSpace(myParent)){
myResult = Spacing.createSpacing(0, 0, 0, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
}
}
}
}
示例6: doInit
import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private void doInit(ASTNode child, CommonCodeStyleSettings settings, JavaCodeStyleSettings javaSettings)
{
if(isErrorElement(child))
{
myResult = Spacing.getReadOnlySpacing();
return;
}
init(child);
mySettings = settings;
myJavaSettings = javaSettings;
if(myChild1 == null)
{
// Given node corresponds to the first document block.
if(FormatterUtil.isFormatterCalledExplicitly())
{
createSpaceInCode(false);
}
return;
}
final PsiElement myChild1Psi1 = myChild1.getPsi();
final PsiElement myChild1Psi2 = myChild2.getPsi();
if(myChild1Psi1 == null || myChild1Psi1.getLanguage() != JavaLanguage.INSTANCE || myChild1Psi2 == null || myChild1Psi2.getLanguage() != JavaLanguage.INSTANCE)
{
return;
}
if(myChild2 != null && StdTokenSets.COMMENT_BIT_SET.contains(myChild2.getElementType()))
{
if(myChild2.getElementType() == JavaTokenType.C_STYLE_COMMENT)
{
myResult = Spacing.getReadOnlySpacing();
}
else if(mySettings.KEEP_FIRST_COLUMN_COMMENT)
{
myResult = Spacing.createKeepingFirstColumnSpacing(0, Integer.MAX_VALUE, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else
{
myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 0, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
}
else if(myParent != null)
{
myParent.accept(this);
if(myResult == null)
{
final ASTNode prev = getPrevElementType(myChild2);
if(prev != null && prev.getElementType() == JavaTokenType.END_OF_LINE_COMMENT)
{
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else if(!canStickChildrenTogether(myChild1, myChild2))
{
myResult = Spacing.createSpacing(1, Integer.MIN_VALUE, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else if(myChild1.getElementType() == JavaTokenType.C_STYLE_COMMENT)
{
myResult = null;
}
else if(!shouldKeepSpace(myParent))
{
myResult = Spacing.createSpacing(0, 0, 0, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
}
}
}