Java 类com.intellij.psi.impl.GeneratedMarkerVisitor 实例源码

项目:intellij-ce-playground    文件:CDATAOnAnyEncodedPolicy.java   
@SuppressWarnings({"HardCodedStringLiteral"})
public static FileElement createCDATAElement(final PsiManager manager, final CharTable charTableByTree, final String displayText) {
  final FileElement dummyParent = DummyHolderFactory.createHolder(manager, null, charTableByTree).getTreeElement();
  final CompositeElement cdata = ASTFactory.composite(XmlElementType.XML_CDATA);
  dummyParent.rawAddChildren(cdata);
  cdata.rawAddChildren(ASTFactory.leaf(XmlTokenType.XML_CDATA_START, "<![CDATA["));
  cdata.rawAddChildren(ASTFactory.leaf(XmlTokenType.XML_DATA_CHARACTERS, dummyParent.getCharTable().intern(displayText)));
  cdata.rawAddChildren(ASTFactory.leaf(XmlTokenType.XML_CDATA_END, "]]>"));
  dummyParent.acceptTree(new GeneratedMarkerVisitor());
  return dummyParent;
}
项目:tools-idea    文件:CDATAOnAnyEncodedPolicy.java   
@SuppressWarnings({"HardCodedStringLiteral"})
public static FileElement createCDATAElement(final PsiManager manager, final CharTable charTableByTree, final String displayText) {
  final FileElement dummyParent = DummyHolderFactory.createHolder(manager, null, charTableByTree).getTreeElement();
  final CompositeElement cdata = ASTFactory.composite(XmlElementType.XML_CDATA);
  dummyParent.rawAddChildren(cdata);
  cdata.rawAddChildren(ASTFactory.leaf(XmlTokenType.XML_CDATA_START, "<![CDATA["));
  cdata.rawAddChildren(ASTFactory.leaf(XmlTokenType.XML_DATA_CHARACTERS, dummyParent.getCharTable().intern(displayText)));
  cdata.rawAddChildren(ASTFactory.leaf(XmlTokenType.XML_CDATA_END, "]]>"));
  dummyParent.acceptTree(new GeneratedMarkerVisitor());
  return dummyParent;
}
项目:consulo-xml    文件:CDATAOnAnyEncodedPolicy.java   
@SuppressWarnings({"HardCodedStringLiteral"})
public static FileElement createCDATAElement(final PsiManager manager, final CharTable charTableByTree, final String displayText) {
  final FileElement dummyParent = DummyHolderFactory.createHolder(manager, null, charTableByTree).getTreeElement();
  final CompositeElement cdata = ASTFactory.composite(XmlElementType.XML_CDATA);
  dummyParent.rawAddChildren(cdata);
  cdata.rawAddChildren(ASTFactory.leaf(XmlTokenType.XML_CDATA_START, "<![CDATA["));
  cdata.rawAddChildren(ASTFactory.leaf(XmlTokenType.XML_DATA_CHARACTERS, dummyParent.getCharTable().intern(displayText)));
  cdata.rawAddChildren(ASTFactory.leaf(XmlTokenType.XML_CDATA_END, "]]>"));
  dummyParent.acceptTree(new GeneratedMarkerVisitor());
  return dummyParent;
}
项目:consulo-java    文件:JavaTreeGenerator.java   
private static TreeElement markGeneratedIfNeeded(@NotNull PsiElement original, @NotNull TreeElement copy)
{
    if(CodeEditUtil.isNodeGenerated(original.getNode()))
    {
        copy.acceptTree(new GeneratedMarkerVisitor());
    }
    return copy;
}
项目:consulo-java    文件:JavaTreeGenerator.java   
private static TreeElement createReference(final Project project, final String text, boolean mark)
{
    final PsiJavaParserFacade parserFacade = JavaPsiFacade.getInstance(project).getParserFacade();
    final TreeElement element = (TreeElement) parserFacade.createReferenceFromText(text, null).getNode();
    if(mark)
    {
        element.acceptTree(new GeneratedMarkerVisitor());
    }
    return element;
}
项目:intellij-ce-playground    文件:JavaTreeGenerator.java   
private static TreeElement markGeneratedIfNeeded(@NotNull PsiElement original, @NotNull TreeElement copy) {
  if (CodeEditUtil.isNodeGenerated(original.getNode())) {
    copy.acceptTree(new GeneratedMarkerVisitor());
  }
  return copy;
}
项目:intellij-ce-playground    文件:JavaTreeGenerator.java   
private static TreeElement createReference(final Project project, final String text, boolean mark) {
  final PsiJavaParserFacade parserFacade = JavaPsiFacade.getInstance(project).getParserFacade();
  final TreeElement element = (TreeElement)parserFacade.createReferenceFromText(text, null).getNode();
  if (mark) element.acceptTree(new GeneratedMarkerVisitor());
  return element;
}
项目:intellij-ce-playground    文件:JavaSharedImplUtil.java   
public static void normalizeBrackets(@NotNull PsiVariable variable) {
  CompositeElement variableElement = (CompositeElement)variable.getNode();

  PsiTypeElement typeElement = variable.getTypeElement();
  PsiIdentifier nameElement = variable.getNameIdentifier();
  LOG.assertTrue(typeElement != null && nameElement != null);

  ASTNode type = typeElement.getNode();
  ASTNode name = nameElement.getNode();

  ASTNode firstBracket = null;
  ASTNode lastBracket = null;
  int arrayCount = 0;
  ASTNode element = name;
  while (element != null) {
    element = PsiImplUtil.skipWhitespaceAndComments(element.getTreeNext());
    if (element == null || element.getElementType() != JavaTokenType.LBRACKET) break;
    if (firstBracket == null) firstBracket = element;
    lastBracket = element;
    arrayCount++;

    element = PsiImplUtil.skipWhitespaceAndComments(element.getTreeNext());
    if (element == null || element.getElementType() != JavaTokenType.RBRACKET) break;
    lastBracket = element;
  }

  if (firstBracket != null) {
    element = firstBracket;
    while (true) {
      ASTNode next = element.getTreeNext();
      variableElement.removeChild(element);
      if (element == lastBracket) break;
      element = next;
    }

    CompositeElement newType = (CompositeElement)type.clone();
    for (int i = 0; i < arrayCount; i++) {
      CompositeElement newType1 = ASTFactory.composite(JavaElementType.TYPE);
      newType1.rawAddChildren(newType);

      newType1.rawAddChildren(ASTFactory.leaf(JavaTokenType.LBRACKET, "["));
      newType1.rawAddChildren(ASTFactory.leaf(JavaTokenType.RBRACKET, "]"));
      newType = newType1;
      newType.acceptTree(new GeneratedMarkerVisitor());
    }
    newType.putUserData(CharTable.CHAR_TABLE_KEY, SharedImplUtil.findCharTableByTree(type));
    variableElement.replaceChild(type, newType);
  }
}
项目:tools-idea    文件:JavaSharedImplUtil.java   
public static void normalizeBrackets(@NotNull PsiVariable variable) {
  CompositeElement variableElement = (CompositeElement)variable.getNode();

  PsiTypeElement typeElement = variable.getTypeElement();
  PsiIdentifier nameElement = variable.getNameIdentifier();
  LOG.assertTrue(typeElement != null && nameElement != null);

  ASTNode type = typeElement.getNode();
  ASTNode name = nameElement.getNode();

  ASTNode firstBracket = null;
  ASTNode lastBracket = null;
  int arrayCount = 0;
  ASTNode element = name;
  while (element != null) {
    element = PsiImplUtil.skipWhitespaceAndComments(element.getTreeNext());
    if (element == null || element.getElementType() != JavaTokenType.LBRACKET) break;
    if (firstBracket == null) firstBracket = element;
    lastBracket = element;
    arrayCount++;

    element = PsiImplUtil.skipWhitespaceAndComments(element.getTreeNext());
    if (element == null || element.getElementType() != JavaTokenType.RBRACKET) break;
    lastBracket = element;
  }

  if (firstBracket != null) {
    element = firstBracket;
    while (true) {
      ASTNode next = element.getTreeNext();
      variableElement.removeChild(element);
      if (element == lastBracket) break;
      element = next;
    }

    CompositeElement newType = (CompositeElement)type.clone();
    for (int i = 0; i < arrayCount; i++) {
      CompositeElement newType1 = ASTFactory.composite(JavaElementType.TYPE);
      newType1.rawAddChildren(newType);

      newType1.rawAddChildren(ASTFactory.leaf(JavaTokenType.LBRACKET, "["));
      newType1.rawAddChildren(ASTFactory.leaf(JavaTokenType.RBRACKET, "]"));
      newType = newType1;
      newType.acceptTree(new GeneratedMarkerVisitor());
    }
    newType.putUserData(CharTable.CHAR_TABLE_KEY, SharedImplUtil.findCharTableByTree(type));
    variableElement.replaceChild(type, newType);
  }
}
项目:tools-idea    文件:JavaTreeGenerator.java   
private static TreeElement markGeneratedIfNeeded(PsiElement original, TreeElement copy) {
  if (CodeEditUtil.isNodeGenerated(original.getNode())) {
    copy.acceptTree(new GeneratedMarkerVisitor());
  }
  return copy;
}
项目:tools-idea    文件:JavaTreeGenerator.java   
private static TreeElement createReference(final Project project, final String text, boolean mark) {
  final PsiJavaParserFacade parserFacade = JavaPsiFacade.getInstance(project).getParserFacade();
  final TreeElement element = (TreeElement)parserFacade.createReferenceFromText(text, null).getNode();
  if (mark) element.acceptTree(new GeneratedMarkerVisitor());
  return element;
}
项目:consulo-java    文件:JavaSharedImplUtil.java   
public static void normalizeBrackets(@NotNull PsiVariable variable)
{
    CompositeElement variableElement = (CompositeElement) variable.getNode();

    PsiTypeElement typeElement = variable.getTypeElement();
    PsiIdentifier nameElement = variable.getNameIdentifier();
    LOG.assertTrue(typeElement != null && nameElement != null);

    ASTNode type = typeElement.getNode();
    ASTNode name = nameElement.getNode();

    ASTNode firstBracket = null;
    ASTNode lastBracket = null;
    int arrayCount = 0;
    ASTNode element = name;
    while(element != null)
    {
        element = PsiImplUtil.skipWhitespaceAndComments(element.getTreeNext());
        if(element == null || element.getElementType() != JavaTokenType.LBRACKET)
        {
            break;
        }
        if(firstBracket == null)
        {
            firstBracket = element;
        }
        lastBracket = element;
        arrayCount++;

        element = PsiImplUtil.skipWhitespaceAndComments(element.getTreeNext());
        if(element == null || element.getElementType() != JavaTokenType.RBRACKET)
        {
            break;
        }
        lastBracket = element;
    }

    if(firstBracket != null)
    {
        element = firstBracket;
        while(true)
        {
            ASTNode next = element.getTreeNext();
            variableElement.removeChild(element);
            if(element == lastBracket)
            {
                break;
            }
            element = next;
        }

        CompositeElement newType = (CompositeElement) type.clone();
        for(int i = 0; i < arrayCount; i++)
        {
            CompositeElement newType1 = ASTFactory.composite(JavaElementType.TYPE);
            newType1.rawAddChildren(newType);

            newType1.rawAddChildren(ASTFactory.leaf(JavaTokenType.LBRACKET, "["));
            newType1.rawAddChildren(ASTFactory.leaf(JavaTokenType.RBRACKET, "]"));
            newType = newType1;
            newType.acceptTree(new GeneratedMarkerVisitor());
        }
        newType.putUserData(CharTable.CHAR_TABLE_KEY, SharedImplUtil.findCharTableByTree(type));
        variableElement.replaceChild(type, newType);
    }
}