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


Java Spacing.createDependentLFSpacing方法代码示例

本文整理汇总了Java中com.intellij.formatting.Spacing.createDependentLFSpacing方法的典型用法代码示例。如果您正苦于以下问题:Java Spacing.createDependentLFSpacing方法的具体用法?Java Spacing.createDependentLFSpacing怎么用?Java Spacing.createDependentLFSpacing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.formatting.Spacing的用法示例。


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

示例1: createDependentSpacingForClosure

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
@NotNull
static Spacing createDependentSpacingForClosure(@NotNull CommonCodeStyleSettings settings,
                                                @NotNull GroovyCodeStyleSettings groovySettings,
                                                @NotNull GrClosableBlock closure,
                                                final boolean forArrow) {
  boolean spaceWithinBraces = closure.getParent() instanceof GrStringInjection
                              ? groovySettings.SPACE_WITHIN_GSTRING_INJECTION_BRACES
                              : settings.SPACE_WITHIN_BRACES;
  GrStatement[] statements = closure.getStatements();
  if (statements.length > 0) {
    final PsiElement startElem = forArrow ? statements[0] : closure;
    int start = startElem.getTextRange().getStartOffset();
    int end = statements[statements.length - 1].getTextRange().getEndOffset();
    TextRange range = new TextRange(start, end);

    int minSpaces = spaceWithinBraces || forArrow ? 1 : 0;
    int maxSpaces = spaceWithinBraces || forArrow ? 1 : 0;
    return Spacing.createDependentLFSpacing(minSpaces, maxSpaces, range, settings.KEEP_LINE_BREAKS, settings.KEEP_BLANK_LINES_IN_CODE);
  }
  return spaceWithinBraces || forArrow ? COMMON_SPACING : NO_SPACING_WITH_NEWLINE;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GroovySpacingProcessorBasic.java

示例2: setBraceSpace

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
public Spacing setBraceSpace(boolean needSpaceSetting,
                             @CommonCodeStyleSettings.BraceStyleConstant int braceStyleSetting,
                             TextRange textRange, ASTNode child2) {
    final int spaces = needSpaceSetting ? 1 : 0;
    IElementType parentType = child2.getTreeParent().getElementType();

    // Don't wrap simple block event if line breaks set to NEXT_LINE (unless there are manual line breaks)
    if (braceStyleSetting == CommonCodeStyleSettings.NEXT_LINE && SquirrelFormatterUtil.isSimpleBlock(child2) &&
            ((parentType == FUNCTION_BODY && cmSettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE) ||
                    (parentType == CLASS_DECLARATION && cmSettings.KEEP_SIMPLE_CLASSES_IN_ONE_LINE) ||
                    (parentType != FUNCTION_BODY && parentType != CLASS_DECLARATION && cmSettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE))
            ) {
        return Spacing.createSpacing(spaces, spaces, 0, cmSettings.KEEP_LINE_BREAKS,
                cmSettings.KEEP_BLANK_LINES_IN_CODE);
    }

    else if (braceStyleSetting == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED && textRange != null) {
        return Spacing.createDependentLFSpacing(spaces, spaces, textRange, cmSettings.KEEP_LINE_BREAKS,
                cmSettings.KEEP_BLANK_LINES_IN_CODE);
    }
    else {
        final int lineBreaks = (braceStyleSetting == CommonCodeStyleSettings.END_OF_LINE || braceStyleSetting == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) ? 0: 1;
        return Spacing.createSpacing(spaces, spaces, lineBreaks, false, 0);
    }
}
 
开发者ID:shvetsgroup,项目名称:squirrel-lang-idea-plugin,代码行数:26,代码来源:SquirrelSpacingProcessor.java

示例3: processOnNewLineCondition

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private void processOnNewLineCondition(boolean onNewLine, boolean createSpaceInline)
{
	if(onNewLine)
	{
		if(!mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE)
		{
			myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
		}
		else
		{
			myResult = Spacing.createDependentLFSpacing(0, 1, myParent.getTextRange(), mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
		}
	}
	else
	{
		createSpaceProperty(createSpaceInline, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:JavaSpacePropertyProcessor.java

示例4: createNonLFSpace

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private Spacing createNonLFSpace(int spaces, @Nullable TextRange dependantRange)
{
	final ASTNode prev = getPrevElementType(myChild2);
	if(prev != null && prev.getElementType() == JavaTokenType.END_OF_LINE_COMMENT)
	{
		return Spacing.createSpacing(0, Integer.MAX_VALUE, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
	}
	else if(dependantRange != null)
	{
		return Spacing.createDependentLFSpacing(spaces, spaces, dependantRange, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
	}
	else
	{
		return Spacing.createSpacing(spaces, spaces, 0, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:JavaSpacePropertyProcessor.java

示例5: processOnNewLineCondition

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private void processOnNewLineCondition(final boolean onNewLine, final boolean createSpaceInline) {
  if (onNewLine) {
    if (!mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE) {
      myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
    }
    else {
      myResult = Spacing.createDependentLFSpacing(0, 1, myParent.getTextRange(), mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
    }
  }
  else {
    createSpaceProperty(createSpaceInline, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JavaSpacePropertyProcessor.java

示例6: visitForeachStatement

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
@Override
public void visitForeachStatement(PsiForeachStatement statement) {
  if (myRole1 == ChildRole.FOR_KEYWORD && myRole2 == ChildRole.LPARENTH) {
    createSpaceInCode(mySettings.SPACE_BEFORE_FOR_PARENTHESES);
  }
  else if (myRole1 == ChildRole.LPARENTH || myRole2 == ChildRole.RPARENTH) {
    createSpaceInCode(mySettings.SPACE_WITHIN_FOR_PARENTHESES);
  }
  else if (myRole1 == ChildRole.FOR_ITERATION_PARAMETER && myRole2 == ChildRole.COLON ||
           myRole1 == ChildRole.COLON && myRole2 == ChildRole.FOR_ITERATED_VALUE)
  {
    createSpaceInCode(true);
  }
  else if (myRole2 == ChildRole.LOOP_BODY) {
    if (myChild2.getElementType() == JavaElementType.BLOCK_STATEMENT) {
      myResult = getSpaceBeforeLBrace(myChild2, mySettings.SPACE_BEFORE_FOR_LBRACE, null);
    }
    else if (mySettings.KEEP_CONTROL_STATEMENT_IN_ONE_LINE) {
      myResult = Spacing.createDependentLFSpacing(1, 1, myParent.getTextRange(), false, mySettings.KEEP_BLANK_LINES_IN_CODE);
    }
    else {
      myResult = Spacing.createSpacing(0, 0, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
    }

  }

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:JavaSpacePropertyProcessor.java

示例7: createNonLFSpace

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private Spacing createNonLFSpace(int spaces, @Nullable final TextRange dependantRange, final boolean keepLineBreaks) {
  final ASTNode prev = getPrevElementType(myChild2);
  if (prev != null && prev.getElementType() == JavaTokenType.END_OF_LINE_COMMENT) {
    return Spacing.createSpacing(0, Integer.MAX_VALUE, 1, keepLineBreaks, mySettings.KEEP_BLANK_LINES_IN_CODE);
  }
  else if (dependantRange != null) {
    return Spacing.createDependentLFSpacing(spaces, spaces, dependantRange, keepLineBreaks, mySettings.KEEP_BLANK_LINES_IN_CODE);
  }
  else {
    return Spacing.createSpacing(spaces, spaces, 0, keepLineBreaks, mySettings.KEEP_BLANK_LINES_IN_CODE);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JavaSpacePropertyProcessor.java

示例8: createParenthSpace

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private void createParenthSpace(final boolean onNewLine, final boolean space, final TextRange dependence) {
  if (onNewLine) {
    final int spaces = space ? 1 : 0;
    myResult = Spacing.createDependentLFSpacing(spaces, spaces, dependence, mySettings.KEEP_LINE_BREAKS,
                                                mySettings.KEEP_BLANK_LINES_IN_CODE);
  }
  else {
    createSpaceInCode(space);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JavaSpacePropertyProcessor.java

示例9: createDependentLFSpacing

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private void createDependentLFSpacing(final boolean isLineFeed, final boolean isSpace, @NotNull final TextRange range) {
  if (isLineFeed) {
    myResult = Spacing.createDependentLFSpacing(isSpace ? 1 : 0, isSpace ? 1 : 0, range, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
  }
  else {
    createSpaceInCode(isSpace);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:GroovySpacingProcessor.java

示例10: processTryOnNewLineCondition

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private void processTryOnNewLineCondition(boolean onNewLine, boolean spaceIfNotNewLine) {
  if (onNewLine) {
    if (mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE) {
      myResult = Spacing.createDependentLFSpacing(0, 1, myParent.getTextRange(), mySettings.KEEP_LINE_BREAKS, keepBlankLines());
    }
    else {
      createLF(true);
    }
  }
  else {
    createSpaceInCode(spaceIfNotNewLine);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:GroovySpacingProcessor.java

示例11: createNonLFSpace

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private Spacing createNonLFSpace(int spaces, @Nullable final TextRange dependantRange, final boolean keepLineBreaks) {
  final ASTNode prev = FormatterUtil.getPreviousNonWhitespaceLeaf(myChild2);
  if (prev != null && prev.getElementType() == GroovyTokenTypes.mSL_COMMENT) {
    return Spacing.createSpacing(0, Integer.MAX_VALUE, 1, keepLineBreaks, keepBlankLines());
  }
  else if (dependantRange != null) {
    return Spacing.createDependentLFSpacing(spaces, spaces, dependantRange, keepLineBreaks, keepBlankLines());
  }
  else {
    return Spacing.createSpacing(spaces, spaces, 0, keepLineBreaks, keepBlankLines());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:GroovySpacingProcessor.java

示例12: processOnNewLineCondition

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private void processOnNewLineCondition(final boolean onNewLine, final boolean createSpaceInline) {
  if (onNewLine) {
    if (!mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE) {
      myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
    }
    else {
      myResult = Spacing
        .createDependentLFSpacing(0, 1, myParent.getTextRange(), mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
    }
  }
  else {
    createSpaceProperty(createSpaceInline, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:JavaSpacePropertyProcessor.java

示例13: visitForeachStatement

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
@Override public void visitForeachStatement(PsiForeachStatement statement) {
  if (myRole1 == ChildRole.FOR_KEYWORD && myRole2 == ChildRole.LPARENTH) {
    createSpaceInCode(mySettings.SPACE_BEFORE_FOR_PARENTHESES);
  }
  else if (myRole1 == ChildRole.LPARENTH || myRole2 == ChildRole.RPARENTH) {
    createSpaceInCode(mySettings.SPACE_WITHIN_FOR_PARENTHESES);
  }
  else if (myRole1 == ChildRole.FOR_ITERATION_PARAMETER && myRole2 == ChildRole.COLON ||
           myRole1 == ChildRole.COLON && myRole2 == ChildRole.FOR_ITERATED_VALUE)
  {
    createSpaceInCode(true);
  }
  else if (myRole2 == ChildRole.LOOP_BODY) {
    if (myChild2.getElementType() == JavaElementType.BLOCK_STATEMENT) {
      myResult = getSpaceBeforeLBrace(mySettings.SPACE_BEFORE_FOR_LBRACE, mySettings.BRACE_STYLE,
                                      new TextRange(myParent.getTextRange().getStartOffset(), myChild1.getTextRange().getEndOffset()),
                                      mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE, true);
    }
    else if (mySettings.KEEP_CONTROL_STATEMENT_IN_ONE_LINE) {
      myResult = Spacing
        .createDependentLFSpacing(1, 1, myParent.getTextRange(), false, mySettings.KEEP_BLANK_LINES_IN_CODE);
    }
    else {
      myResult = Spacing.createSpacing(0, 0, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
    }

  }

}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:JavaSpacePropertyProcessor.java

示例14: createNonLFSpace

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private Spacing createNonLFSpace(int spaces, @Nullable final TextRange dependantRange, final boolean keepLineBreaks) {
  final ASTNode prev = getPrevElementType(myChild2);
  if (prev != null && prev.getElementType() == JavaTokenType.END_OF_LINE_COMMENT) {
    return Spacing
      .createSpacing(0, Integer.MAX_VALUE, 1, keepLineBreaks, mySettings.KEEP_BLANK_LINES_IN_CODE);
  }
  else if (dependantRange != null) {
    return Spacing
      .createDependentLFSpacing(spaces, spaces, dependantRange, keepLineBreaks, mySettings.KEEP_BLANK_LINES_IN_CODE);
  }
  else {
    return Spacing.createSpacing(spaces, spaces, 0, keepLineBreaks, mySettings.KEEP_BLANK_LINES_IN_CODE);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:JavaSpacePropertyProcessor.java

示例15: getSpaceBeforeLBrace

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private Spacing getSpaceBeforeLBrace(final boolean spaceBeforeLbrace,
                                     @CommonCodeStyleSettings.BraceStyleConstant int braceStyle,
                                     @Nullable TextRange dependantRange,
                                     boolean keepOneLine,
                                     boolean useParentBlockAsDependencyAllTheTime)
{
  int space = spaceBeforeLbrace ? 1 : 0;
  if (dependantRange != null && braceStyle == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) {
    return createNonLFSpace(space, dependantRange, false);
  }
  else if (braceStyle == CommonCodeStyleSettings.END_OF_LINE || braceStyle == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) {
    return createNonLFSpace(space, null, false);
  }
  else if (braceStyle == CommonCodeStyleSettings.NEXT_LINE && !mySettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE) {
    space = (keepOneLine && spaceBeforeLbrace) ? 1 : 0;
    return Spacing.createSpacing(space, 0, keepOneLine ? 0 : 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
  }
  else if (keepOneLine) {
    TextRange dependencyRangeToUse = dependantRange == null || useParentBlockAsDependencyAllTheTime
                                     ? myParent.getTextRange() : dependantRange;

    return Spacing.createDependentLFSpacing(
      space, space, dependencyRangeToUse, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE
    );
  }
  else {
    return Spacing.createSpacing(0, 0, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:JavaSpacePropertyProcessor.java


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