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


Java AbstractBlock类代码示例

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


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

示例1: toString

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
public String toString() {
  ASTNode treeNode = null;
  Block child = mySubBlocks.get(0);
  while (treeNode == null) {
    if (child instanceof AbstractBlock) {
      treeNode = ((AbstractBlock)child).getNode();
    }
    else if (child instanceof SyntheticCodeBlock) {
      child = ((SyntheticCodeBlock)child).mySubBlocks.get(0);
    }
    else {
      break;
    }
  }
  final TextRange textRange = getTextRange();
  if (treeNode != null) {
    PsiElement psi = treeNode.getPsi();
    if (psi != null) {
      PsiFile file = psi.getContainingFile();
      if (file != null) {
        return file.getText().subSequence(textRange.getStartOffset(), textRange.getEndOffset()) + " " + textRange;
      }
    }
  }
  return getClass().getName() + ": " + textRange;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:SyntheticCodeBlock.java

示例2: getIndentOnStartOffset

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
private static List<Indent.Type> getIndentOnStartOffset(Block block, TextRange range, int startOffset) {
  List<Indent.Type> indentsOnStartOffset = new ArrayList<Indent.Type>();
  
  while (block != null && range.getStartOffset() == startOffset) {
    Indent.Type type = block.getIndent() != null ? block.getIndent().getType() : Indent.Type.CONTINUATION_WITHOUT_FIRST;
    indentsOnStartOffset.add(type);
    
    if (block instanceof AbstractBlock) {
      ((AbstractBlock)block).setBuildIndentsOnly(true);
    }
    List<Block> subBlocks = block.getSubBlocks();
    block = subBlocks.isEmpty() ? null : subBlocks.get(0);
  }
  
  return indentsOnStartOffset;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:FormatterBasedLineIndentInfoBuilder.java

示例3: createDummyBlock

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
protected AbstractBlock createDummyBlock(final ASTNode node) {
  return new AbstractBlock(node, Wrap.createWrap(WrapType.NONE, false), Alignment.createAlignment()) {
    @Override
    protected List<Block> buildChildren() {
      return Collections.emptyList();
    }

    @Override
    public Spacing getSpacing(final Block child1, @NotNull final Block child2) {
      return Spacing.getReadOnlySpacing();
    }

    @Override
    public boolean isLeaf() {
      return true;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:TemplateLanguageFormattingModelBuilder.java

示例4: getIndentOnStartOffset

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
private static List<Indent.Type> getIndentOnStartOffset(Block block, TextRange range, int startOffset) {
  List<Indent.Type> indentsOnStartOffset = new ArrayList<Indent.Type>();

  while (block != null && range.getStartOffset() == startOffset) {
    Indent.Type type = block.getIndent() != null ? block.getIndent().getType() : Indent.Type.CONTINUATION_WITHOUT_FIRST;
    indentsOnStartOffset.add(type);

    if (block instanceof AbstractBlock) {
      ((AbstractBlock)block).setBuildIndentsOnly(true);
    }
    List<Block> subBlocks = block.getSubBlocks();
    block = subBlocks.isEmpty() ? null : subBlocks.get(0);
  }

  return indentsOnStartOffset;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:FormatterBasedLineIndentInfoBuilder.java

示例5: createDummyBlock

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
protected AbstractBlock createDummyBlock(final ASTNode node) {
  return new AbstractBlock(node, Wrap.createWrap(WrapType.NONE, false), Alignment.createAlignment()) {
    @Override
    protected List<Block> buildChildren() {
      return Collections.emptyList();
    }

    @Override
    public Spacing getSpacing(final Block child1, @Nonnull final Block child2) {
      return Spacing.getReadOnlySpacing();
    }

    @Override
    public boolean isLeaf() {
      return true;
    }
  };
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:TemplateLanguageFormattingModelBuilder.java

示例6: isAfter

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
protected boolean isAfter(final int newChildIndex, @NotNull final IElementType[] elementTypes)
{
	if(newChildIndex == 0)
	{
		return false;
	}
	final Block previousBlock = getSubBlocks().get(newChildIndex - 1);
	if(!(previousBlock instanceof AbstractBlock))
	{
		return false;
	}
	final IElementType previousElementType = ((AbstractBlock) previousBlock).getNode().getElementType();
	for(IElementType elementType : elementTypes)
	{
		if(previousElementType == elementType)
		{
			return true;
		}
	}
	return false;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:AbstractJavaBlock.java

示例7: isQuotedField

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
public static boolean isQuotedField(@Nullable CsvBlock block) {
    if (block != null && block.getNode().getElementType() == CsvTypes.FIELD) {
        List<Block> subBlocks = block.buildChildren();
        if (subBlocks.size() > 0) {
            AbstractBlock abstractBlock = (AbstractBlock) subBlocks.get(0);
            return abstractBlock.getNode().getElementType() == CsvTypes.QUOTE;
        }
    }
    return false;
}
 
开发者ID:SeeSharpSoft,项目名称:intellij-csv-validator,代码行数:11,代码来源:CsvFormatHelper.java

示例8: isAfter

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
protected boolean isAfter(final int newChildIndex, @NotNull final IElementType[] elementTypes) {
  if (newChildIndex == 0) return false;
  final Block previousBlock = getSubBlocks().get(newChildIndex - 1);
  if (!(previousBlock instanceof AbstractBlock)) return false;
  final IElementType previousElementType = ((AbstractBlock)previousBlock).getNode().getElementType();
  for (IElementType elementType : elementTypes) {
    if (previousElementType == elementType) return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:AbstractJavaBlock.java

示例9: createCaseSectionBlock

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
private SyntheticCodeBlock createCaseSectionBlock(final ArrayList<Block> localResult, final Alignment childAlignment, final Indent indent,
                                                  final Wrap childWrap) {
  final SyntheticCodeBlock result = new SyntheticCodeBlock(localResult, childAlignment, getSettings(), myJavaSettings, indent, childWrap) {
    @Override
    @NotNull
    public ChildAttributes getChildAttributes(final int newChildIndex) {
      IElementType prevElementType = null;
      if (newChildIndex > 0) {
        final Block previousBlock = getSubBlocks().get(newChildIndex - 1);
        if (previousBlock instanceof AbstractBlock) {
          prevElementType = ((AbstractBlock)previousBlock).getNode().getElementType();
        }
      }

      if (prevElementType == JavaElementType.BLOCK_STATEMENT
          || prevElementType == JavaElementType.BREAK_STATEMENT
          || prevElementType == JavaElementType.RETURN_STATEMENT) {
        return new ChildAttributes(Indent.getNoneIndent(), null);
      }
      else {
        return super.getChildAttributes(newChildIndex);
      }
    }

  };
  result.setChildAttributes(new ChildAttributes(Indent.getNormalIndent(), null));
  result.setIsIncomplete(true);
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:CodeBlockBlock.java

示例10: createModel

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
@Override
@NotNull
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  if (element instanceof PsiFile) {
    final FileViewProvider viewProvider = ((PsiFile)element).getViewProvider();
    if (viewProvider instanceof TemplateLanguageFileViewProvider) {
      final Language language = ((TemplateLanguageFileViewProvider)viewProvider).getTemplateDataLanguage();
      FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forLanguage(language);
      if (builder != null) {
        return builder.createModel(viewProvider.getPsi(language), settings);
      }
    }
  }

  final PsiFile file = element.getContainingFile();
  return new DocumentBasedFormattingModel(new AbstractBlock(element.getNode(), Wrap.createWrap(WrapType.NONE, false), Alignment.createAlignment()) {
    @Override
    protected List<Block> buildChildren() {
      return Collections.emptyList();
    }

    @Override
    public Spacing getSpacing(final Block child1, @NotNull final Block child2) {
      return Spacing.getReadOnlySpacing();
    }

    @Override
    public boolean isLeaf() {
      return true;
    }
  }, element.getProject(), settings, file.getFileType(), file);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:SimpleTemplateLanguageFormattingModelBuilder.java

示例11: getFirstNode

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
private ASTNode getFirstNode(final List<Block> subBlocks) {
  LOG.assertTrue(!subBlocks.isEmpty());
  final Block firstBlock = subBlocks.get(0);
  if (firstBlock instanceof AbstractBlock) {
    return ((AbstractBlock)firstBlock).getNode();
  }
  else {
    return getFirstNode(firstBlock.getSubBlocks());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:AbstractSyntheticBlock.java

示例12: getLastNode

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
private ASTNode getLastNode(final List<Block> subBlocks) {
  LOG.assertTrue(!subBlocks.isEmpty());
  final Block lastBlock = subBlocks.get(subBlocks.size() - 1);
  if (lastBlock instanceof AbstractBlock) {
    return ((AbstractBlock)lastBlock).getNode();
  }
  else {
    return getLastNode(lastBlock.getSubBlocks());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:AbstractSyntheticBlock.java

示例13: getSpacing

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
@Override
public Spacing getSpacing(Block child1, @NotNull Block child2) {
  if (!(child1 instanceof AbstractBlock) || !(child2 instanceof AbstractBlock)) {
    return null;
  }

  final IElementType elementType = myNode.getElementType();
  final ASTNode node1 = ((AbstractBlock)child1).getNode();
  final IElementType type1 = node1.getElementType();
  final ASTNode node2 = ((AbstractBlock)child2).getNode();
  final IElementType type2 = node2.getElementType();

  if ((isXmlTag(node2) || type2 == XmlTokenType.XML_END_TAG_START || type2 == XmlElementType.XML_TEXT) && myXmlFormattingPolicy
    .getShouldKeepWhiteSpaces()) {
    return Spacing.getReadOnlySpacing();
  }

  if (elementType == XmlElementType.XML_TEXT) {
    return getSpacesInsideText(type1, type2);

  }
  else if (elementType == XmlElementType.XML_ATTRIBUTE) {
    return getSpacesInsideAttribute(type1, type2);
  }

  if (type1 == XmlElementType.XML_PROLOG) {
    return createDefaultSpace(true, false);
  }

  if (elementType == XmlElementType.XML_DOCTYPE) {
    return createDefaultSpace(true, false);
  }

  return createDefaultSpace(false, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:XmlBlock.java

示例14: createCaseSectionBlock

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
private SyntheticCodeBlock createCaseSectionBlock(final ArrayList<Block> localResult, final Alignment childAlignment, final Indent indent,
                                                  final Wrap childWrap) {
  final SyntheticCodeBlock result = new SyntheticCodeBlock(localResult, childAlignment, getSettings(), indent, childWrap) {
    @Override
    @NotNull
    public ChildAttributes getChildAttributes(final int newChildIndex) {
      IElementType prevElementType = null;
      if (newChildIndex > 0) {
        final Block previousBlock = getSubBlocks().get(newChildIndex - 1);
        if (previousBlock instanceof AbstractBlock) {
          prevElementType = ((AbstractBlock)previousBlock).getNode().getElementType();
        }
      }

      if (prevElementType == JavaElementType.BLOCK_STATEMENT
          || prevElementType == JavaElementType.BREAK_STATEMENT
          || prevElementType == JavaElementType.RETURN_STATEMENT) {
        return new ChildAttributes(Indent.getNoneIndent(), null);
      }
      else {
        return super.getChildAttributes(newChildIndex);
      }
    }

  };
  result.setChildAttributes(new ChildAttributes(Indent.getNormalIndent(), null));
  result.setIsIncomplete(true);
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:CodeBlockBlock.java

示例15: getSpacing

import com.intellij.psi.formatter.common.AbstractBlock; //导入依赖的package包/类
public Spacing getSpacing(Block child1, @NotNull Block child2) {
  if (!(child1 instanceof AbstractBlock) || !(child2 instanceof AbstractBlock)) {
    return null;
  }

  final IElementType elementType = myNode.getElementType();
  final ASTNode node1 = ((AbstractBlock)child1).getNode();
  final IElementType type1 = node1.getElementType();
  final ASTNode node2 = ((AbstractBlock)child2).getNode();
  final IElementType type2 = node2.getElementType();

  if ((isXmlTag(node2) || type2 == XmlElementType.XML_END_TAG_START || type2 == XmlElementType.XML_TEXT) && myXmlFormattingPolicy
    .getShouldKeepWhiteSpaces()) {
    return Spacing.getReadOnlySpacing();
  }

  if (elementType == XmlElementType.XML_TEXT) {
    return getSpacesInsideText(type1, type2);

  }
  else if (elementType == XmlElementType.XML_ATTRIBUTE) {
    return getSpacesInsideAttribute(type1, type2);
  }

  if (type1 == XmlElementType.XML_PROLOG) {
    return createDefaultSpace(true, false);
  }

  if (elementType == XmlElementType.XML_DOCTYPE) {
    return createDefaultSpace(true, false);
  }

  return createDefaultSpace(false, false);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:35,代码来源:XmlBlock.java


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