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


Java Spacing.createSpacing方法代码示例

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


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

示例1: getSpacing

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
@Nullable
@Override
public Spacing getSpacing(@Nullable Block child1, @NotNull Block child2) {
    if (!formattingInfo.getCsvCodeStyleSettings().TABULARIZE || formattingInfo.getCsvCodeStyleSettings().WHITE_SPACES_OUTSIDE_QUOTES || child1 == null) {
        return null;
    }
    int spaces = 0;
    CsvBlockElement block1 = (CsvBlockElement) child1;
    CsvBlockElement block2 = (CsvBlockElement) child2;
    if ((block1.getElementType() == CsvTypes.QUOTE && formattingInfo.getCsvCodeStyleSettings().LEADING_WHITE_SPACES) ||
            (block2.getElementType() == CsvTypes.QUOTE && !formattingInfo.getCsvCodeStyleSettings().LEADING_WHITE_SPACES)) {
        spaces = getColumnInfo().getMaxLength() - getTextLength();
    } else {
        return formattingInfo.getSpacingBuilder().getSpacing(this, child1, child2);
    }
    return Spacing.createSpacing(spaces, spaces, 0, true, 0);
}
 
开发者ID:SeeSharpSoft,项目名称:intellij-csv-validator,代码行数:18,代码来源:CsvBlockField.java

示例2: getSpaceBeforeMethodLBrace

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
@NotNull
private Spacing getSpaceBeforeMethodLBrace(@NotNull PsiMethod method) {
  final int space = mySettings.SPACE_BEFORE_METHOD_LBRACE ? 1 : 0;
  final int methodBraceStyle = mySettings.METHOD_BRACE_STYLE;

  if (methodBraceStyle == CommonCodeStyleSettings.END_OF_LINE) {
    return createNonLFSpace(space, null, false);
  }
  else if (methodBraceStyle == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) {
    TextRange headerRange = new TextRange(getMethodHeaderStartOffset(method), getMethodHeaderEndOffset(method));
    return createNonLFSpace(space, headerRange, false);
  }
  else if (shouldHandleAsSimpleMethod(method)) {
    TextRange rangeWithoutAnnotations = new TextRange(getMethodHeaderStartOffset(method), method.getTextRange().getEndOffset());
    return createNonLFSpace(space, rangeWithoutAnnotations, false);
  }

  return Spacing.createSpacing(space, space, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:JavaSpacePropertyProcessor.java

示例3: getSpaceBeforeClassLBrace

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
@NotNull
private Spacing getSpaceBeforeClassLBrace(@NotNull PsiClass aClass) {
  final int space = mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0;
  final int classBraceStyle = mySettings.CLASS_BRACE_STYLE;

  if (classBraceStyle == CommonCodeStyleSettings.END_OF_LINE || shouldHandleAsSimpleClass(aClass)) {
    return createNonLFSpace(space, null, false);
  }
  else if (classBraceStyle == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) {
    final PsiIdentifier nameIdentifier = aClass.getNameIdentifier();
    final int startOffset = nameIdentifier == null ? myParent.getTextRange().getStartOffset() : nameIdentifier.getTextRange().getStartOffset();
    TextRange range = new TextRange(startOffset, myChild1.getTextRange().getEndOffset());
    return createNonLFSpace(space, range, false);
  }

  return Spacing.createSpacing(space, space, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaSpacePropertyProcessor.java

示例4: visitField

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
@Override
public void visitField(PsiField field) {
  if (myChild1.getElementType() == JavaDocElementType.DOC_COMMENT) {
    myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
    return;
  }

  if (myRole1 == ChildRole.INITIALIZER_EQ || myRole2 == ChildRole.INITIALIZER_EQ) {
    createSpaceInCode(mySettings.SPACE_AROUND_ASSIGNMENT_OPERATORS);
  }
  else if (myRole1 == ChildRole.TYPE || myRole2 == ChildRole.TYPE) {
    createSpaceInCode(true);
  }
  else if (myChild2.getElementType() == JavaTokenType.SEMICOLON) {
    createSpaceProperty(false, false, 0);
  }
  else if (myRole1 == ChildRole.MODIFIER_LIST) {
    createSpaceProperty(true, false, 0);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:JavaSpacePropertyProcessor.java

示例5: 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovySpacingProcessor.java

示例6: visitTypeDefinitionBody

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
@Override
public void visitTypeDefinitionBody(GrTypeDefinitionBody typeDefinitionBody) {
  if (myType1 == GroovyTokenTypes.mLCURLY && myType2 == GroovyTokenTypes.mRCURLY) {
    if (mySettings.KEEP_SIMPLE_CLASSES_IN_ONE_LINE) {
      createSpaceInCode(false);
    }
    else {
      createLF(true);
    }
  }
  else if (myType1 == GroovyTokenTypes.mLCURLY) {
    myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_CLASS_HEADER + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
  }
  else if (myType2 == GroovyTokenTypes.mRCURLY) {
    createLF(true);
  }
  else {
    processClassMembers(typeDefinitionBody);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:GroovySpacingProcessor.java

示例7: 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

示例8: visitTypeDefinitionBody

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
public void visitTypeDefinitionBody(GrTypeDefinitionBody typeDefinitionBody) {
  if (myType1 == mLCURLY && myType2 == mRCURLY) {
    if (mySettings.KEEP_SIMPLE_CLASSES_IN_ONE_LINE) {
      createSpaceInCode(false);
    }
    else {
      createLF(true);
    }
  }
  else if (myType1 == mLCURLY) {
    myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_CLASS_HEADER + 1, mySettings.KEEP_LINE_BREAKS,
                                     mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
  }
  else if (myType2 == mRCURLY) {
    createLF(true);
  }
  else {
    processClassMembers(typeDefinitionBody);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:GroovySpacingProcessor.java

示例9: visitOpenBlock

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
public void visitOpenBlock(GrOpenBlock block) {
  boolean isMethod = block.getParent() instanceof GrMethod;
  boolean keepInOneLine = isMethod ? mySettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE : mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE;

  if (myType1 == mLCURLY && myType2 == mRCURLY) {
    createLF(!keepInOneLine);
  }
  else if (myType1 == mLCURLY) {
    if (keepInOneLine) {
      createDependentLFSpacing(true, mySettings.SPACE_WITHIN_BRACES, block.getTextRange());
    }
    else {
      int lineFeedsCount = isMethod ? mySettings.BLANK_LINES_BEFORE_METHOD_BODY + 1 : 1;
      myResult = Spacing.createSpacing(0, 0, lineFeedsCount, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
    }
  }
  else if (myType2 == mRCURLY) {
    if (keepInOneLine) {
      createDependentLFSpacing(true, mySettings.SPACE_WITHIN_BRACES, block.getTextRange());
    }
    else {
      createLF(true);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:GroovySpacingProcessor.java

示例10: visitExpressionList

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
@Override public void visitExpressionList(PsiExpressionList list) {
  if (myRole1 == ChildRole.LPARENTH && myRole2 == ChildRole.RPARENTH) {
    createParenthSpace(mySettings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE, mySettings.SPACE_WITHIN_EMPTY_METHOD_CALL_PARENTHESES);
  }
  else if (myRole2 == ChildRole.RPARENTH) {
    if (JavaFormatterUtil.hasAnonymousClassesArguments(list, 2)) {
      myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, 0);
    }
    else {
      createParenthSpace(mySettings.CALL_PARAMETERS_RPAREN_ON_NEXT_LINE,
                         myRole1 == ChildRole.COMMA || mySettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES);
    }
  }
  else if (myRole1 == ChildRole.LPARENTH) {
    createParenthSpace(mySettings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE, mySettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES);
  }
  else if (myRole1 == ChildRole.COMMA) {
    createSpaceInCode(mySettings.SPACE_AFTER_COMMA);
  }
  else if (myRole2 == ChildRole.COMMA) {
    createSpaceInCode(false);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:JavaSpacePropertyProcessor.java

示例11: createSpaceProperty

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private void createSpaceProperty(boolean space, boolean keepLineBreaks, final int keepBlankLines) {
  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 (!space && !canStickChildrenTogether(myChild1, myChild2)) {
      space = true;
    }

    if (!keepLineBreaks && myRole2 == ChildRoleBase.NONE) {
      keepLineBreaks = true;
    }
    myResult = Spacing.createSpacing(space ? 1 : 0, space ? 1 : 0, 0, keepLineBreaks, keepBlankLines);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:JavaSpacePropertyProcessor.java

示例12: 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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:GroovySpacingProcessor.java

示例13: 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

示例14: processModifierList

import com.intellij.formatting.Spacing; //导入方法依赖的package包/类
private void processModifierList()
{
	if(mySettings.MODIFIER_LIST_WRAP)
	{
		myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
	}
	else if(myRole1 == ChildRole.MODIFIER_LIST && myRole2 == ChildRole.PACKAGE_KEYWORD)
	{
		myResult = Spacing.createSpacing(1, 1, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
	}
	else if(myRole2 == ChildRole.TYPE && myChild1.getLastChildNode() != null && myChild1.getLastChildNode().getElementType() == JavaElementType.ANNOTATION)
	{
		createSpaceProperty(true, mySettings.KEEP_LINE_BREAKS, 0);
	}
	else
	{
		createSpaceProperty(true, false, 0);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:JavaSpacePropertyProcessor.java

示例15: 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


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