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


Java CharTable类代码示例

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


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

示例1: deleteChildInternal

import com.intellij.util.CharTable; //导入依赖的package包/类
@Override
public void deleteChildInternal(@NotNull ASTNode child) {
  if (child.getElementType() == CODE_BLOCK) {
    final ASTNode prevWS = TreeUtil.prevLeaf(child);
    if (prevWS != null && prevWS.getElementType() == TokenType.WHITE_SPACE) {
      removeChild(prevWS);
    }
    super.deleteChildInternal(child);
    final CharTable treeCharTab = SharedImplUtil.findCharTableByTree(this);
    LeafElement semicolon = Factory.createSingleLeafElement(SEMICOLON, ";", 0, 1, treeCharTab, getManager());
    addInternal(semicolon, semicolon, null, Boolean.TRUE);
  }
  else {
    super.deleteChildInternal(child);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:MethodElement.java

示例2: addNewLineToTag

import com.intellij.util.CharTable; //导入依赖的package包/类
private static void addNewLineToTag(CompositeElement tag, Project project) {
  LOG.assertTrue(tag != null && tag.getElementType() == DOC_TAG);
  ASTNode current = tag.getLastChildNode();
  while (current != null && current.getElementType() == DOC_COMMENT_DATA && isWhitespaceCommentData(current)) {
    current = current.getTreePrev();
  }
  if (current != null && current.getElementType() == DOC_COMMENT_LEADING_ASTERISKS) return;
  final CharTable treeCharTab = SharedImplUtil.findCharTableByTree(tag);
  final ASTNode newLine = Factory.createSingleLeafElement(DOC_COMMENT_DATA, "\n", 0, 1, treeCharTab, SharedImplUtil.getManagerByTree(tag));
  tag.addChild(newLine, null);

  ASTNode leadingWhitespaceAnchor = null;
  if (JavaCodeStyleSettingsFacade.getInstance(project).isJavaDocLeadingAsterisksEnabled()) {
    final TreeElement leadingAsterisk = Factory.createSingleLeafElement(DOC_COMMENT_LEADING_ASTERISKS, "*", 0, 1, treeCharTab,
                                                                        SharedImplUtil.getManagerByTree(tag));

    leadingWhitespaceAnchor = tag.addInternal(leadingAsterisk, leadingAsterisk, null, Boolean.TRUE);
  }

  final TreeElement commentData = Factory.createSingleLeafElement(DOC_COMMENT_DATA, " ", 0, 1, treeCharTab, SharedImplUtil.getManagerByTree(tag));
  tag.addInternal(commentData, commentData, leadingWhitespaceAnchor, Boolean.TRUE);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PsiDocCommentImpl.java

示例3: DummyHolder

import com.intellij.util.CharTable; //导入依赖的package包/类
public DummyHolder(@NotNull PsiManager manager, @Nullable TreeElement contentElement, @Nullable PsiElement context, @Nullable CharTable table, @Nullable Boolean validity, Language language) {
  super(TokenType.DUMMY_HOLDER, TokenType.DUMMY_HOLDER, new DummyHolderViewProvider(manager));
  myLanguage = language;
  ((DummyHolderViewProvider)getViewProvider()).setDummyHolder(this);
  myContext = context;
  myTable = table != null ? table : IdentityCharTable.INSTANCE;
  if (contentElement instanceof FileElement) {
    myFileElement = (FileElement)contentElement;
    myFileElement.setPsi(this);
    myFileElement.setCharTable(myTable);
  }
  else if (contentElement != null) {
    getTreeElement().rawAddChildren(contentElement);
    clearCaches();
  }
  myExplicitlyValid = validity;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:DummyHolder.java

示例4: doFindWhiteSpaceNode

import com.intellij.util.CharTable; //导入依赖的package包/类
@NotNull
private static Pair<PsiElement, CharTable> doFindWhiteSpaceNode(@NotNull PsiFile file, int offset) {
  ASTNode astNode = SourceTreeToPsiMap.psiElementToTree(file);
  if (!(astNode instanceof FileElement)) {
    return new Pair<PsiElement, CharTable>(null, null);
  }
  PsiElement elementAt = InjectedLanguageUtil.findInjectedElementNoCommit(file, offset);
  final CharTable charTable = ((FileElement)astNode).getCharTable();
  if (elementAt == null) {
    elementAt = findElementInTreeWithFormatterEnabled(file, offset);
  }

  if( elementAt == null) {
    return new Pair<PsiElement, CharTable>(null, charTable);
  }
  ASTNode node = elementAt.getNode();
  if (node == null || node.getElementType() != TokenType.WHITE_SPACE) {
    return new Pair<PsiElement, CharTable>(null, charTable);
  }
  return Pair.create(elementAt, charTable);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CodeStyleManagerImpl.java

示例5: createCharEntity

import com.intellij.util.CharTable; //导入依赖的package包/类
@SuppressWarnings({"HardCodedStringLiteral"})
private static TreeElement createCharEntity(char ch, CharTable charTable) {
  switch (ch) {
    case '<':
      return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, "&lt;");
    case '\'':
      return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, "&apos;");
    case '"':
      return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, "&quot;");
    case '>':
      return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, "&gt;");
    case '&':
      return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, "&amp;");
    case '\u00a0':
      return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, "&nbsp;");

    default:
      final String charEncoding = "&#" + (int)ch + ";";
      return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, charTable.intern(charEncoding));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:EncodeEachSymbolPolicy.java

示例6: deleteChildInternal

import com.intellij.util.CharTable; //导入依赖的package包/类
@Override
public void deleteChildInternal(@NotNull ASTNode child) {
  if (child.getElementType() == CODE_BLOCK){
    final ASTNode prevWS = TreeUtil.prevLeaf(child);
    if (prevWS != null && prevWS.getElementType() == TokenType.WHITE_SPACE) {
      removeChild(prevWS);
    }
    super.deleteChildInternal(child);
    final CharTable treeCharTab = SharedImplUtil.findCharTableByTree(this);
    LeafElement semicolon = Factory.createSingleLeafElement(SEMICOLON, ";", 0, 1, treeCharTab, getManager());
    addInternal(semicolon, semicolon, null, Boolean.TRUE);
  }
  else {
    super.deleteChildInternal(child);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:MethodElement.java

示例7: PsiBuilderImpl

import com.intellij.util.CharTable; //导入依赖的package包/类
public PsiBuilderImpl(Project project,
                      PsiFile containingFile,
                      @NotNull TokenSet whiteSpaces,
                      @NotNull TokenSet comments,
                      @NotNull Lexer lexer,
                      CharTable charTable,
                      @NotNull final CharSequence text,
                      @Nullable ASTNode originalTree,
                      @Nullable MyTreeStructure parentLightTree) {
  myProject = project;
  myFile = containingFile;

  myText = text;
  myTextArray = CharArrayUtil.fromSequenceWithoutCopying(text);
  myLexer = lexer;

  myWhitespaces = whiteSpaces;
  myComments = comments;
  myCharTable = charTable;
  myOriginalTree = originalTree;
  myParentLightTree = parentLightTree;

  cacheLexemes();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:PsiBuilderImpl.java

示例8: doFindWhiteSpaceNode

import com.intellij.util.CharTable; //导入依赖的package包/类
@NotNull
private static Pair<PsiElement, CharTable> doFindWhiteSpaceNode(@NotNull PsiFile file, int offset) {
  ASTNode astNode = SourceTreeToPsiMap.psiElementToTree(file);
  if (!(astNode instanceof FileElement)) {
    return new Pair<PsiElement, CharTable>(null, null);
  }
  PsiElement elementAt = InjectedLanguageUtil.findInjectedElementNoCommit(file, offset);
  final CharTable charTable = ((FileElement)astNode).getCharTable();
  if (elementAt == null) {
    elementAt = findElementInTreeWithFormatterEnabled(file, offset);
  }

  if( elementAt == null) {
    return new Pair<PsiElement, CharTable>(null, charTable);
  }
  ASTNode node = elementAt.getNode();
  if (node == null || node.getElementType() != TokenType.WHITE_SPACE) {
    return new Pair<PsiElement, CharTable>(null, charTable);
  }
  return new Pair<PsiElement, CharTable>(elementAt, charTable);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:CodeStyleManagerImpl.java

示例9: DummyHolder

import com.intellij.util.CharTable; //导入依赖的package包/类
public DummyHolder(@Nonnull PsiManager manager, @Nullable TreeElement contentElement, @Nullable PsiElement context, @Nullable CharTable table, @Nullable Boolean validity, Language language) {
  super(TokenType.DUMMY_HOLDER, TokenType.DUMMY_HOLDER, new DummyHolderViewProvider(manager));
  myLanguage = language;
  ((DummyHolderViewProvider)getViewProvider()).setDummyHolder(this);
  myContext = context;
  myTable = table != null ? table : IdentityCharTable.INSTANCE;
  if (contentElement instanceof FileElement) {
    ((FileElement)contentElement).setPsi(this);
    ((FileElement)contentElement).setCharTable(myTable);
    setTreeElementPointer((FileElement)contentElement);
  }
  else if (contentElement != null) {
    getTreeElement().rawAddChildren(contentElement);
    clearCaches();
  }
  myExplicitlyValid = validity;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:DummyHolder.java

示例10: doFindWhiteSpaceNode

import com.intellij.util.CharTable; //导入依赖的package包/类
@Nonnull
private static Pair<PsiElement, CharTable> doFindWhiteSpaceNode(@Nonnull PsiFile file, int offset) {
  ASTNode astNode = SourceTreeToPsiMap.psiElementToTree(file);
  if (!(astNode instanceof FileElement)) {
    return new Pair<>(null, null);
  }
  PsiElement elementAt = InjectedLanguageManager.getInstance(file.getProject()).findInjectedElementAt(file, offset);
  final CharTable charTable = ((FileElement)astNode).getCharTable();
  if (elementAt == null) {
    elementAt = findElementInTreeWithFormatterEnabled(file, offset);
  }

  if( elementAt == null) {
    return new Pair<>(null, charTable);
  }
  ASTNode node = elementAt.getNode();
  if (node == null || node.getElementType() != TokenType.WHITE_SPACE) {
    return new Pair<>(null, charTable);
  }
  return Pair.create(elementAt, charTable);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:CodeStyleManagerImpl.java

示例11: scanChildren

import com.intellij.util.CharTable; //导入依赖的package包/类
private static void scanChildren(CompositeElement element, ASTNode node, TokenSet listTypes, boolean forward)
{
	ASTNode child = node;
	while(true)
	{
		child = (forward ? child.getTreeNext() : child.getTreePrev());
		if(child == null || child.getElementType() == JavaTokenType.COMMA)
		{
			break;
		}
		if(listTypes.contains(child.getElementType()))
		{
			CharTable charTable = SharedImplUtil.findCharTableByTree(element);
			PsiManager manager = element.getPsi().getManager();
			TreeElement comma = Factory.createSingleLeafElement(JavaTokenType.COMMA, ",", 0, 1, charTable,
					manager);
			element.addInternal(comma, comma, (forward ? node : child), Boolean.FALSE);
			break;
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:JavaSourceUtil.java

示例12: deleteChildInternal

import com.intellij.util.CharTable; //导入依赖的package包/类
@Override
public void deleteChildInternal(@NotNull ASTNode child)
{
	if(child.getElementType() == CODE_BLOCK)
	{
		final ASTNode prevWS = TreeUtil.prevLeaf(child);
		if(prevWS != null && prevWS.getElementType() == TokenType.WHITE_SPACE)
		{
			removeChild(prevWS);
		}
		super.deleteChildInternal(child);
		final CharTable treeCharTab = SharedImplUtil.findCharTableByTree(this);
		LeafElement semicolon = Factory.createSingleLeafElement(SEMICOLON, ";", 0, 1, treeCharTab, getManager());
		addInternal(semicolon, semicolon, null, Boolean.TRUE);
	}
	else
	{
		super.deleteChildInternal(child);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:MethodElement.java

示例13: addParenthToReplacedChild

import com.intellij.util.CharTable; //导入依赖的package包/类
public static TreeElement addParenthToReplacedChild(@NotNull IElementType parenthType,
                                                    @NotNull TreeElement newChild,
                                                    @NotNull PsiManager manager) {
  CompositeElement parenthExpr = ASTFactory.composite(parenthType);

  TreeElement dummyExpr = (TreeElement)newChild.clone();
  final CharTable charTableByTree = SharedImplUtil.findCharTableByTree(newChild);
  new DummyHolder(manager, parenthExpr, null, charTableByTree);
  parenthExpr.putUserData(CharTable.CHAR_TABLE_KEY, charTableByTree);
  parenthExpr.rawAddChildren(ASTFactory.leaf(JavaTokenType.LPARENTH, "("));
  parenthExpr.rawAddChildren(dummyExpr);
  parenthExpr.rawAddChildren(ASTFactory.leaf(JavaTokenType.RPARENTH, ")"));

  try {
    CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
    PsiElement formatted = codeStyleManager.reformat(SourceTreeToPsiMap.treeToPsiNotNull(parenthExpr));
    parenthExpr = (CompositeElement)SourceTreeToPsiMap.psiToTreeNotNull(formatted);
  }
  catch (IncorrectOperationException e) {
    LOG.error(e); // should not happen
  }

  newChild.putUserData(CharTable.CHAR_TABLE_KEY, SharedImplUtil.findCharTableByTree(newChild));
  dummyExpr.getTreeParent().replaceChild(dummyExpr, newChild);

  // TODO remove explicit caches drop since this should be ok if we will use ChangeUtil for the modification
  TreeUtil.clearCaches(TreeUtil.getFileElement(parenthExpr));
  return parenthExpr;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:JavaSourceUtil.java

示例14: scanChildren

import com.intellij.util.CharTable; //导入依赖的package包/类
private static void scanChildren(CompositeElement element, ASTNode node, TokenSet listTypes, boolean forward) {
  ASTNode child = node;
  while (true) {
    child = (forward ? child.getTreeNext() : child.getTreePrev());
    if (child == null || child.getElementType() == JavaTokenType.COMMA) break;
    if (listTypes.contains(child.getElementType())) {
      CharTable charTable = SharedImplUtil.findCharTableByTree(element);
      PsiManager manager = element.getPsi().getManager();
      TreeElement comma = Factory.createSingleLeafElement(JavaTokenType.COMMA, ",", 0, 1, charTable, manager);
      element.addInternal(comma, comma, (forward ? node : child), Boolean.FALSE);
      break;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JavaSourceUtil.java

示例15: addInternal

import com.intellij.util.CharTable; //导入依赖的package包/类
@Override
public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before){
  if (first == last && first.getElementType() == JavaElementType.TYPE){
    if (getLastChildNode() != null && getLastChildNode().getElementType() == TokenType.ERROR_ELEMENT){
      super.deleteChildInternal(getLastChildNode());
    }
  }

  final CharTable treeCharTab = SharedImplUtil.findCharTableByTree(this);

  if (getFirstChildNode()== null || getFirstChildNode().getElementType() != JavaTokenType.LT){
    TreeElement lt = Factory.createSingleLeafElement(JavaTokenType.LT, "<", 0, 1, treeCharTab, getManager());
    super.addInternal(lt, lt, getFirstChildNode(), Boolean.TRUE);
  }
  if (getLastChildNode() == null || getLastChildNode().getElementType() != JavaTokenType.GT){
    TreeElement gt = Factory.createSingleLeafElement(JavaTokenType.GT, ">", 0, 1, treeCharTab, getManager());
    super.addInternal(gt, gt, getLastChildNode(), Boolean.FALSE);
  }

  if (anchor == null){
    if (before == null || before.booleanValue()){
      anchor = findChildByRole(ChildRole.GT_IN_TYPE_LIST);
      before = Boolean.TRUE;
    }
    else{
      anchor = findChildByRole(ChildRole.LT_IN_TYPE_LIST);
      before = Boolean.FALSE;
    }
  }

  final TreeElement firstAdded = super.addInternal(first, last, anchor, before);

  if (first == last && first.getElementType() == JavaElementType.TYPE) {
    JavaSourceUtil.addSeparatingComma(this, first, TYPE_SET);
  }

  return firstAdded;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:PsiReferenceParameterListImpl.java


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