Java 类com.intellij.psi.impl.source.tree.JavaDocElementType 实例源码

项目:intellij-ce-playground    文件:SimpleJavaBlock.java   
private void processHeadCommentsAndWhiteSpaces(@NotNull List<Block> result) {
  while (myCurrentChild != null) {
    if (StdTokenSets.COMMENT_BIT_SET.contains(myCurrentChild.getElementType()) || myCurrentChild.getElementType() == JavaDocElementType.DOC_COMMENT) {
      Block commentBlock = createJavaBlock(
        myCurrentChild,
        mySettings, myJavaSettings,
        Indent.getNoneIndent(), null, AlignmentStrategy.getNullStrategy()
      );
      result.add(commentBlock);
      myCurrentIndent = Indent.getNoneIndent();
    }
    else if (!FormatterUtil.containsWhiteSpacesOnly(myCurrentChild)) {
      break;
    }

    myCurrentOffset += myCurrentChild.getTextLength();
    myCurrentChild = myCurrentChild.getTreeNext();
  }
}
项目:tools-idea    文件:JavadocParser.java   
private static void parseSeeTagValue(@NotNull final PsiBuilder builder) {
  final IElementType tokenType = getTokenType(builder);
  if (tokenType == JavaDocTokenType.DOC_TAG_VALUE_SHARP_TOKEN) {
    parseMethodRef(builder, builder.mark());
  }
  else if (tokenType == JavaDocTokenType.DOC_TAG_VALUE_TOKEN) {
    final PsiBuilder.Marker refStart = builder.mark();
    builder.remapCurrentToken(JavaDocElementType.DOC_REFERENCE_HOLDER);
    builder.advanceLexer();

    if (getTokenType(builder) == JavaDocTokenType.DOC_TAG_VALUE_SHARP_TOKEN) {
      parseMethodRef(builder, refStart);
    }
    else {
      refStart.drop();
    }
  }
  else {
    final PsiBuilder.Marker tagValue = builder.mark();
    builder.advanceLexer();
    tagValue.done(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
  }
}
项目:tools-idea    文件:JavaHighlightingLexer.java   
public JavaHighlightingLexer(LanguageLevel languageLevel) {
  super(JavaParserDefinition.createLexer(languageLevel));
  registerSelfStoppingLayer(new StringLiteralLexer('\"', JavaTokenType.STRING_LITERAL),
                            new IElementType[]{JavaTokenType.STRING_LITERAL}, IElementType.EMPTY_ARRAY);

  registerSelfStoppingLayer(new StringLiteralLexer('\'', JavaTokenType.STRING_LITERAL),
                            new IElementType[]{JavaTokenType.CHARACTER_LITERAL}, IElementType.EMPTY_ARRAY);

  LayeredLexer docLexer = new LayeredLexer(JavaParserDefinition.createDocLexer(languageLevel));

  HtmlHighlightingLexer lexer = new HtmlHighlightingLexer();
  lexer.setHasNoEmbeddments(true);
  docLexer.registerLayer(lexer, JavaDocTokenType.DOC_COMMENT_DATA);

  registerSelfStoppingLayer(docLexer, new IElementType[]{JavaDocElementType.DOC_COMMENT}, IElementType.EMPTY_ARRAY);
}
项目:consulo-java    文件:JavadocParser.java   
private static void parseTag(@NotNull final PsiBuilder builder)
{
    final String tagName = builder.getTokenText();
    final PsiBuilder.Marker tag = builder.mark();
    builder.advanceLexer();
    while(true)
    {
        final IElementType tokenType = getTokenType(builder);
        if(tokenType == null || tokenType == JavaDocTokenType.DOC_TAG_NAME || tokenType == JavaDocTokenType.DOC_COMMENT_END)
        {
            break;
        }
        parseDataItem(builder, tagName, false);
    }
    tag.done(JavaDocElementType.DOC_TAG);
}
项目:consulo-java    文件:JavadocParser.java   
private static void parseSeeTagValue(@NotNull final PsiBuilder builder, boolean allowBareFieldReference)
{
    final IElementType tokenType = getTokenType(builder);
    if(tokenType == JavaDocTokenType.DOC_TAG_VALUE_SHARP_TOKEN)
    {
        parseMethodRef(builder, builder.mark());
    }
    else if(tokenType == JavaDocTokenType.DOC_TAG_VALUE_TOKEN)
    {
        final PsiBuilder.Marker refStart = builder.mark();
        builder.remapCurrentToken(JavaDocElementType.DOC_REFERENCE_HOLDER);
        builder.advanceLexer();

        if(getTokenType(builder) == JavaDocTokenType.DOC_TAG_VALUE_SHARP_TOKEN)
        {
            parseMethodRef(builder, refStart);
        }
        else if(allowBareFieldReference)
        {
            refStart.rollbackTo();
            builder.remapCurrentToken(JavaDocTokenType.DOC_TAG_VALUE_TOKEN);
            parseMethodRef(builder, builder.mark());
        }
        else
        {
            refStart.drop();
        }
    }
    else
    {
        final PsiBuilder.Marker tagValue = builder.mark();
        builder.advanceLexer();
        tagValue.done(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
    }
}
项目:consulo-java    文件:JavaLightStubBuilder.java   
private static boolean checkByTypes(IElementType parentType, IElementType nodeType)
{
    if(ElementType.IMPORT_STATEMENT_BASE_BIT_SET.contains(parentType))
    {
        return true;
    }
    if(nodeType == JavaElementType.RECEIVER_PARAMETER)
    {
        return true;
    }
    if(nodeType == JavaElementType.PARAMETER && parentType != JavaElementType.PARAMETER_LIST)
    {
        return true;
    }
    if(nodeType == JavaElementType.PARAMETER_LIST && parentType == JavaElementType.LAMBDA_EXPRESSION)
    {
        return true;
    }
    if(nodeType == JavaDocElementType.DOC_COMMENT)
    {
        return true;
    }

    return false;
}
项目:consulo-java    文件:PsiImplUtil.java   
@Nullable
public static ASTNode findDocComment(@NotNull CompositeElement element)
{
    TreeElement node = element.getFirstChildNode();
    while(node != null && (isWhitespaceOrComment(node) && !(node.getPsi() instanceof PsiDocComment)))
    {
        node = node.getTreeNext();
    }

    if(node != null && node.getElementType() == JavaDocElementType.DOC_COMMENT)
    {
        return node;
    }
    else
    {
        return null;
    }
}
项目:consulo-java    文件:SimpleJavaBlock.java   
private void processHeadCommentsAndWhiteSpaces(@NotNull List<Block> result)
{
    while(myCurrentChild != null)
    {
        if(StdTokenSets.COMMENT_BIT_SET.contains(myCurrentChild.getElementType()) || myCurrentChild.getElementType() == JavaDocElementType.DOC_COMMENT)
        {
            Block commentBlock = createJavaBlock(myCurrentChild, mySettings, myJavaSettings, Indent.getNoneIndent(), null, AlignmentStrategy.getNullStrategy());
            result.add(commentBlock);
            myCurrentIndent = Indent.getNoneIndent();
        }
        else if(!FormatterUtil.containsWhiteSpacesOnly(myCurrentChild))
        {
            break;
        }

        myCurrentOffset += myCurrentChild.getTextLength();
        myCurrentChild = myCurrentChild.getTreeNext();
    }
}
项目:consulo-java    文件:BlockContainingJavaBlock.java   
private static boolean isPartOfCodeBlock(final ASTNode child)
{
    if(child == null)
    {
        return false;
    }
    if(child.getElementType() == JavaElementType.BLOCK_STATEMENT)
    {
        return true;
    }
    if(child.getElementType() == JavaElementType.CODE_BLOCK)
    {
        return true;
    }

    if(FormatterUtil.containsWhiteSpacesOnly(child))
    {
        return isPartOfCodeBlock(child.getTreeNext());
    }
    if(child.getElementType() == JavaTokenType.END_OF_LINE_COMMENT)
    {
        return isPartOfCodeBlock(child.getTreeNext());
    }
    return child.getElementType() == JavaDocElementType.DOC_COMMENT;
}
项目:consulo-java    文件:CodeBlockBlock.java   
@Override
@NotNull
public ChildAttributes getChildAttributes(final int newChildIndex)
{
    if(isAfter(newChildIndex, new IElementType[]{
            JavaDocElementType.DOC_COMMENT,
            JavaElementType.MODIFIER_LIST
    }))
    {
        return new ChildAttributes(Indent.getNoneIndent(), null);
    }
    else
    {
        if(getSubBlocks().size() == newChildIndex)
        {
            return new ChildAttributes(Indent.getNoneIndent(), null);
        }
        else
        {
            return new ChildAttributes(getCodeBlockInternalIndent(myChildrenIndent), null);
        }
    }
}
项目:consulo-java    文件:JavaSpacePropertyProcessor.java   
private static boolean shouldKeepSpace(final PsiElement parent)
{
    ASTNode node = parent.getNode();
    if(node == null)
    {
        return true;
    }

    final IElementType type = node.getElementType();
    if(type == JavaDocElementType.DOC_TAG_VALUE_ELEMENT)
    {
        return PsiTreeUtil.getParentOfType(parent, PsiDocMethodOrFieldRef.class) != null;
    }

    return type == JavaDocElementType.DOC_COMMENT || type == JavaDocElementType.DOC_TAG || type == JavaDocElementType.DOC_INLINE_TAG;
}
项目:consulo-java    文件:JavaSpacePropertyProcessor.java   
@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);
    }
}
项目:consulo-java    文件:JavaSpacePropertyProcessor.java   
@Override
public void visitElement(PsiElement element)
{
    if(myRole1 == ChildRole.MODIFIER_LIST)
    {
        processModifierList();
    }
    else if(myRole1 == ChildRole.OPERATION_SIGN)
    {
        createSpaceInCode(mySettings.SPACE_AROUND_UNARY_OPERATOR);
    }
    else if((myType1 == JavaDocTokenType.DOC_TAG_VALUE_TOKEN || myType1 == JavaDocElementType.DOC_TAG_VALUE_ELEMENT) && (myType2 == JavaDocTokenType.DOC_TAG_VALUE_TOKEN || myType2 ==
            JavaDocElementType.DOC_TAG_VALUE_ELEMENT))
    {
        createSpaceInCode(true);
    }
    else if(myRole1 == ChildRole.COMMA)
    {
        createSpaceInCode(mySettings.SPACE_AFTER_COMMA);
    }
    else if(myRole2 == ChildRole.COMMA)
    {
        createSpaceInCode(mySettings.SPACE_BEFORE_COMMA);
    }
}
项目:consulo-java    文件:JavaHighlightingLexer.java   
public JavaHighlightingLexer(LanguageLevel languageLevel) {
  super(new JavaLexer(languageLevel));
  registerSelfStoppingLayer(new StringLiteralLexer('\"', JavaTokenType.STRING_LITERAL),
                            new IElementType[]{JavaTokenType.STRING_LITERAL}, IElementType.EMPTY_ARRAY);

  registerSelfStoppingLayer(new StringLiteralLexer('\'', JavaTokenType.STRING_LITERAL),
                            new IElementType[]{JavaTokenType.CHARACTER_LITERAL}, IElementType.EMPTY_ARRAY);

  LayeredLexer docLexer = new LayeredLexer(new JavaDocLexer(languageLevel));

  HtmlHighlightingLexer lexer = new HtmlHighlightingLexer();
  lexer.setHasNoEmbeddments(true);
  docLexer.registerLayer(lexer, JavaDocTokenType.DOC_COMMENT_DATA);

  registerSelfStoppingLayer(docLexer, new IElementType[]{JavaDocElementType.DOC_COMMENT}, IElementType.EMPTY_ARRAY);
}
项目:intellij-ce-playground    文件:JavadocParser.java   
private static void parseTag(@NotNull final PsiBuilder builder) {
  final String tagName = builder.getTokenText();
  final PsiBuilder.Marker tag = builder.mark();
  builder.advanceLexer();
  while (true) {
    final IElementType tokenType = getTokenType(builder);
    if (tokenType == null || tokenType == JavaDocTokenType.DOC_TAG_NAME || tokenType == JavaDocTokenType.DOC_COMMENT_END) break;
    parseDataItem(builder, tagName, false);
  }
  tag.done(JavaDocElementType.DOC_TAG);
}
项目:intellij-ce-playground    文件:JavadocParser.java   
private static void parseSeeTagValue(@NotNull final PsiBuilder builder, boolean allowBareFieldReference) {
  final IElementType tokenType = getTokenType(builder);
  if (tokenType == JavaDocTokenType.DOC_TAG_VALUE_SHARP_TOKEN) {
    parseMethodRef(builder, builder.mark());
  }
  else if (tokenType == JavaDocTokenType.DOC_TAG_VALUE_TOKEN) {
    final PsiBuilder.Marker refStart = builder.mark();
    builder.remapCurrentToken(JavaDocElementType.DOC_REFERENCE_HOLDER);
    builder.advanceLexer();

    if (getTokenType(builder) == JavaDocTokenType.DOC_TAG_VALUE_SHARP_TOKEN) {
      parseMethodRef(builder, refStart);
    }
    else if (allowBareFieldReference) {
      refStart.rollbackTo();
      builder.remapCurrentToken(JavaDocTokenType.DOC_TAG_VALUE_TOKEN);
      parseMethodRef(builder, builder.mark());
    }
    else {
      refStart.drop();
    }
  }
  else {
    final PsiBuilder.Marker tagValue = builder.mark();
    builder.advanceLexer();
    tagValue.done(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
  }
}
项目:intellij-ce-playground    文件:JavadocParser.java   
private static void parseSimpleTagValue(@NotNull final PsiBuilder builder, final boolean parameter) {
  final PsiBuilder.Marker tagValue = builder.mark();
  while (TAG_VALUES_SET.contains(getTokenType(builder))) {
    builder.advanceLexer();
  }
  tagValue.done(parameter ? JavaDocElementType.DOC_PARAMETER_REF : JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
}
项目:intellij-ce-playground    文件:JavaParserUtil.java   
@Override
public int getEdgePosition(final List<IElementType> tokens, final boolean atStreamEdge, final TokenTextGetter
  getter) {
  if (tokens.size() == 0) return 0;

  // 1. bind doc comment
  for (int idx = tokens.size() - 1; idx >= 0; idx--) {
    if (tokens.get(idx) == JavaDocElementType.DOC_COMMENT) return idx;
  }

  // 2. bind plain comments
  int result = tokens.size();
  for (int idx = tokens.size() - 1; idx >= 0; idx--) {
    final IElementType tokenType = tokens.get(idx);
    if (ElementType.JAVA_WHITESPACE_BIT_SET.contains(tokenType)) {
      if (StringUtil.getLineBreakCount(getter.get(idx)) > 1) break;
    }
    else if (ElementType.JAVA_PLAIN_COMMENT_BIT_SET.contains(tokenType)) {
      if (atStreamEdge ||
          (idx == 0 && myAfterEmptyImport) ||
          (idx > 0 && ElementType.JAVA_WHITESPACE_BIT_SET.contains(tokens.get(idx - 1)) && StringUtil.containsLineBreak(getter.get(idx - 1)))) {
        result = idx;
      }
    }
    else break;
  }

  return result;
}
项目:intellij-ce-playground    文件:JavaFieldStubElementType.java   
@Override
public PsiFieldStub createStub(final LighterAST tree, final LighterASTNode node, final StubElement parentStub) {
  final TypeInfo typeInfo = TypeInfo.create(tree, node, parentStub);

  boolean isDeprecatedByComment = false;
  boolean hasDeprecatedAnnotation = false;
  boolean hasDocComment = false;
  String name = null;
  String initializer = null;

  boolean expectingInit = false;
  for (final LighterASTNode child : tree.getChildren(node)) {
    final IElementType type = child.getTokenType();
    if (type == JavaDocElementType.DOC_COMMENT) {
      hasDocComment = true;
      isDeprecatedByComment = RecordUtil.isDeprecatedByDocComment(tree, child);
    }
    else if (type == JavaElementType.MODIFIER_LIST) {
      hasDeprecatedAnnotation = RecordUtil.isDeprecatedByAnnotation(tree, child);
    }
    else if (type == JavaTokenType.IDENTIFIER) {
      name = RecordUtil.intern(tree.getCharTable(), child);
    }
    else if (type == JavaTokenType.EQ) {
      expectingInit = true;
    }
    else if (expectingInit && !ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(type) && type != JavaTokenType.SEMICOLON) {
      initializer = encodeInitializer(tree, child);
      break;
    }
  }

  final boolean isEnumConst = node.getTokenType() == JavaElementType.ENUM_CONSTANT;
  final byte flags = PsiFieldStubImpl.packFlags(isEnumConst, isDeprecatedByComment, hasDeprecatedAnnotation, hasDocComment);

  return new PsiFieldStubImpl(parentStub, name, typeInfo, initializer, flags);
}
项目:intellij-ce-playground    文件:PsiInlineDocTagImpl.java   
@Override
public PsiDocComment getContainingComment() {
  ASTNode scope = getTreeParent();
  while (scope.getElementType() != JavaDocElementType.DOC_COMMENT) {
    scope = scope.getTreeParent();
  }
  return (PsiDocComment)SourceTreeToPsiMap.treeElementToPsi(scope);
}
项目:intellij-ce-playground    文件:JavaHighlightingLexer.java   
public JavaHighlightingLexer(@NotNull LanguageLevel languageLevel) {
  super(JavaParserDefinition.createLexer(languageLevel));

  registerSelfStoppingLayer(new StringLiteralLexer('\"', JavaTokenType.STRING_LITERAL),
                            new IElementType[]{JavaTokenType.STRING_LITERAL}, IElementType.EMPTY_ARRAY);

  registerSelfStoppingLayer(new StringLiteralLexer('\'', JavaTokenType.STRING_LITERAL),
                            new IElementType[]{JavaTokenType.CHARACTER_LITERAL}, IElementType.EMPTY_ARRAY);

  LayeredLexer docLexer = new LayeredLexer(JavaParserDefinition.createDocLexer(languageLevel));
  HtmlHighlightingLexer htmlLexer = new HtmlHighlightingLexer(null);
  htmlLexer.setHasNoEmbeddments(true);
  docLexer.registerLayer(htmlLexer, JavaDocTokenType.DOC_COMMENT_DATA);
  registerSelfStoppingLayer(docLexer, new IElementType[]{JavaDocElementType.DOC_COMMENT}, IElementType.EMPTY_ARRAY);
}
项目:intellij-ce-playground    文件:JavaDocInfoGenerator.java   
private void generatePackageJavaDoc(final StringBuilder buffer, final PsiPackage psiPackage, boolean generatePrologueAndEpilogue) {
  for (PsiDirectory directory : psiPackage.getDirectories(new EverythingGlobalScope(myProject))) {
    final PsiFile packageInfoFile = directory.findFile(PsiPackage.PACKAGE_INFO_FILE);
    if (packageInfoFile != null) {
      final ASTNode node = packageInfoFile.getNode();
      if (node != null) {
        final ASTNode docCommentNode = node.findChildByType(JavaDocElementType.DOC_COMMENT);
        if (docCommentNode != null) {
          final PsiDocComment docComment = (PsiDocComment)docCommentNode.getPsi();

          if (generatePrologueAndEpilogue)
            generatePrologue(buffer);

          generateCommonSection(buffer, docComment);

          if (generatePrologueAndEpilogue)
            generateEpilogue(buffer);
          break;
        }
      }
    }
    PsiFile packageHtmlFile = directory.findFile("package.html");
    if (packageHtmlFile != null) {
      generatePackageHtmlJavaDoc(buffer, packageHtmlFile, generatePrologueAndEpilogue);
      break;
    }
  }
}
项目:intellij-ce-playground    文件:BlockContainingJavaBlock.java   
private static boolean isPartOfCodeBlock(final ASTNode child) {
  if (child == null) return false;
  if (child.getElementType() == JavaElementType.BLOCK_STATEMENT) return true;
  if (child.getElementType() == JavaElementType.CODE_BLOCK) return true;

  if (FormatterUtil.containsWhiteSpacesOnly(child)) return isPartOfCodeBlock(child.getTreeNext());
  if (child.getElementType() == JavaTokenType.END_OF_LINE_COMMENT) return isPartOfCodeBlock(child.getTreeNext());
  return child.getElementType() == JavaDocElementType.DOC_COMMENT;
}
项目:intellij-ce-playground    文件:CodeBlockBlock.java   
@Override
@NotNull
public ChildAttributes getChildAttributes(final int newChildIndex) {
  if (isAfter(newChildIndex, new IElementType[]{JavaDocElementType.DOC_COMMENT, JavaElementType.MODIFIER_LIST})) {
    return new ChildAttributes(Indent.getNoneIndent(), null);
  }
  else {
    if (getSubBlocks().size() == newChildIndex) {
      return new ChildAttributes(Indent.getNoneIndent(), null);
    }
    else {
      return new ChildAttributes(getCodeBlockInternalIndent(myChildrenIndent), null);
    }
  }
}
项目:intellij-ce-playground    文件:FormSourceCodeGenerator.java   
private static boolean lexemsEqual(final PsiClass classToBind, final PsiClass newClass) {
  Lexer oldTextLexer = JavaParserDefinition.createLexer(LanguageLevel.HIGHEST);
  Lexer newTextLexer = JavaParserDefinition.createLexer(LanguageLevel.HIGHEST);
  String oldBuffer = classToBind.getText();
  String newBuffer = newClass.getText();
  oldTextLexer.start(oldBuffer);
  newTextLexer.start(newBuffer);

  while(true) {
    IElementType oldLexem = oldTextLexer.getTokenType();
    IElementType newLexem = newTextLexer.getTokenType();
    if (oldLexem == null || newLexem == null) {
      // must terminate at the same time
      return oldLexem == null && newLexem == null;
    }
    if (oldLexem != newLexem) {
      return false;
    }
    if (oldLexem != TokenType.WHITE_SPACE && oldLexem != JavaDocElementType.DOC_COMMENT) {
      int oldStart = oldTextLexer.getTokenStart();
      int newStart = newTextLexer.getTokenStart();
      int oldLength = oldTextLexer.getTokenEnd() - oldTextLexer.getTokenStart();
      int newLength = newTextLexer.getTokenEnd() - newTextLexer.getTokenStart();
      if (oldLength != newLength) {
        return false;
      }
      for(int i=0; i<oldLength; i++) {
        if (oldBuffer.charAt(oldStart+i) != newBuffer.charAt(newStart+i)) {
          return false;
        }
      }
    }
    oldTextLexer.advance();
    newTextLexer.advance();
  }
}
项目:tools-idea    文件:JavaDocInfoGenerator.java   
private void generatePackageJavaDoc(final StringBuilder buffer, final PsiPackage psiPackage, boolean generatePrologueAndEpilogue) {
  for(PsiDirectory directory: psiPackage.getDirectories()) {
    final PsiFile packageInfoFile = directory.findFile(PsiPackage.PACKAGE_INFO_FILE);
    if (packageInfoFile != null) {
      final ASTNode node = packageInfoFile.getNode();
      if (node != null) {
        final ASTNode docCommentNode = node.findChildByType(JavaDocElementType.DOC_COMMENT);
        if (docCommentNode != null) {
          final PsiDocComment docComment = (PsiDocComment)docCommentNode.getPsi();

          if (generatePrologueAndEpilogue)
            generatePrologue(buffer);

          generateCommonSection(buffer, docComment);

          if (generatePrologueAndEpilogue)
            generateEpilogue(buffer);
          break;
        }
      }
    }
    PsiFile packageHtmlFile = directory.findFile("package.html");
    if (packageHtmlFile != null) {
      generatePackageHtmlJavaDoc(buffer, packageHtmlFile, generatePrologueAndEpilogue);
      break;
    }
  }
}
项目:tools-idea    文件:JavadocParser.java   
private static void parseTag(@NotNull final PsiBuilder builder) {
  final String tagName = builder.getTokenText();
  final PsiBuilder.Marker tag = builder.mark();
  builder.advanceLexer();
  while (true) {
    final IElementType tokenType = getTokenType(builder);
    if (tokenType == null || tokenType == JavaDocTokenType.DOC_TAG_NAME || tokenType == JavaDocTokenType.DOC_COMMENT_END) break;
    parseDataItem(builder, tagName, false);
  }
  tag.done(JavaDocElementType.DOC_TAG);
}
项目:tools-idea    文件:JavadocParser.java   
private static void parseSimpleTagValue(@NotNull final PsiBuilder builder, final boolean parameter) {
  final PsiBuilder.Marker tagValue = builder.mark();
  while (TAG_VALUES_SET.contains(getTokenType(builder))) {
    builder.advanceLexer();
  }
  tagValue.done(parameter ? JavaDocElementType.DOC_PARAMETER_REF : JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
}
项目:tools-idea    文件:JavaParserUtil.java   
@Override
public int getEdgePosition(final List<IElementType> tokens, final boolean atStreamEdge, final TokenTextGetter
  getter) {
  if (tokens.size() == 0) return 0;

  // 1. bind doc comment
  for (int idx = tokens.size() - 1; idx >= 0; idx--) {
    if (tokens.get(idx) == JavaDocElementType.DOC_COMMENT) return idx;
  }

  // 2. bind plain comments
  int result = tokens.size();
  for (int idx = tokens.size() - 1; idx >= 0; idx--) {
    final IElementType tokenType = tokens.get(idx);
    if (ElementType.JAVA_WHITESPACE_BIT_SET.contains(tokenType)) {
      if (StringUtil.getLineBreakCount(getter.get(idx)) > 1) break;
    }
    else if (ElementType.JAVA_PLAIN_COMMENT_BIT_SET.contains(tokenType)) {
      if (atStreamEdge ||
          (idx == 0 && myAfterEmptyImport) ||
          (idx > 0 && ElementType.JAVA_WHITESPACE_BIT_SET.contains(tokens.get(idx - 1)) && StringUtil.containsLineBreak(getter.get(idx - 1)))) {
        result = idx;
      }
    }
    else break;
  }

  return result;
}
项目:tools-idea    文件:JavaFieldStubElementType.java   
@Override
public PsiFieldStub createStub(final LighterAST tree, final LighterASTNode node, final StubElement parentStub) {
  final TypeInfo typeInfo = TypeInfo.create(tree, node, parentStub);

  boolean isDeprecatedByComment = false;
  boolean hasDeprecatedAnnotation = false;
  String name = null;
  String initializer = null;

  boolean expectingInit = false;
  for (final LighterASTNode child : tree.getChildren(node)) {
    final IElementType type = child.getTokenType();
    if (type == JavaDocElementType.DOC_COMMENT) {
      isDeprecatedByComment = RecordUtil.isDeprecatedByDocComment(tree, child);
    }
    else if (type == JavaElementType.MODIFIER_LIST) {
      hasDeprecatedAnnotation = RecordUtil.isDeprecatedByAnnotation(tree, child);
    }
    else if (type == JavaTokenType.IDENTIFIER) {
      name = RecordUtil.intern(tree.getCharTable(), child);
    }
    else if (type == JavaTokenType.EQ) {
      expectingInit = true;
    }
    else if (expectingInit && !ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(type) && type != JavaTokenType.SEMICOLON) {
      initializer = encodeInitializer(tree, child);
      break;
    }
  }

  final boolean isEnumConst = node.getTokenType() == JavaElementType.ENUM_CONSTANT;
  final byte flags = PsiFieldStubImpl.packFlags(isEnumConst, isDeprecatedByComment, hasDeprecatedAnnotation);

  return new PsiFieldStubImpl(parentStub, name, typeInfo, initializer, flags);
}
项目:tools-idea    文件:PsiInlineDocTagImpl.java   
@Override
public PsiDocComment getContainingComment() {
  ASTNode scope = getTreeParent();
  while (scope.getElementType() != JavaDocElementType.DOC_COMMENT) {
    scope = scope.getTreeParent();
  }
  return (PsiDocComment)SourceTreeToPsiMap.treeElementToPsi(scope);
}
项目:tools-idea    文件:PsiImplUtil.java   
@Nullable
public static ASTNode findDocComment(@NotNull CompositeElement element) {
  TreeElement node = element.getFirstChildNode();
  while (node != null && (isWhitespaceOrComment(node) && !(node.getPsi() instanceof PsiDocComment))) {
    node = node.getTreeNext();
  }

  if (node != null && node.getElementType() == JavaDocElementType.DOC_COMMENT) {
    return node;
  }
  else {
    return null;
  }
}
项目:tools-idea    文件:BlockContainingJavaBlock.java   
private static boolean isPartOfCodeBlock(final ASTNode child) {
  if (child == null) return false;
  if (child.getElementType() == JavaElementType.BLOCK_STATEMENT) return true;
  if (child.getElementType() == JavaElementType.CODE_BLOCK) return true;

  if (FormatterUtil.containsWhiteSpacesOnly(child)) return isPartOfCodeBlock(child.getTreeNext());
  if (child.getElementType() == JavaTokenType.END_OF_LINE_COMMENT) return isPartOfCodeBlock(child.getTreeNext());
  return child.getElementType() == JavaDocElementType.DOC_COMMENT;
}
项目:tools-idea    文件:CodeBlockBlock.java   
@Override
@NotNull
public ChildAttributes getChildAttributes(final int newChildIndex) {
  if (isAfter(newChildIndex, new IElementType[]{JavaDocElementType.DOC_COMMENT, JavaElementType.MODIFIER_LIST})) {
    return new ChildAttributes(Indent.getNoneIndent(), null);
  }
  else {
    if (getSubBlocks().size() == newChildIndex) {
      return new ChildAttributes(Indent.getNoneIndent(), null);
    }
    else {
      return new ChildAttributes(getCodeBlockInternalIndent(myChildrenIndent), null);
    }
  }
}
项目:tools-idea    文件:FormSourceCodeGenerator.java   
private static boolean lexemsEqual(final PsiClass classToBind, final PsiClass newClass) {
  Lexer oldTextLexer = JavaParserDefinition.createLexer(LanguageLevel.HIGHEST);
  Lexer newTextLexer = JavaParserDefinition.createLexer(LanguageLevel.HIGHEST);
  String oldBuffer = classToBind.getText();
  String newBuffer = newClass.getText();
  oldTextLexer.start(oldBuffer);
  newTextLexer.start(newBuffer);

  while(true) {
    IElementType oldLexem = oldTextLexer.getTokenType();
    IElementType newLexem = newTextLexer.getTokenType();
    if (oldLexem == null || newLexem == null) {
      // must terminate at the same time
      return oldLexem == null && newLexem == null;
    }
    if (oldLexem != newLexem) {
      return false;
    }
    if (oldLexem != TokenType.WHITE_SPACE && oldLexem != JavaDocElementType.DOC_COMMENT) {
      int oldStart = oldTextLexer.getTokenStart();
      int newStart = newTextLexer.getTokenStart();
      int oldLength = oldTextLexer.getTokenEnd() - oldTextLexer.getTokenStart();
      int newLength = newTextLexer.getTokenEnd() - newTextLexer.getTokenStart();
      if (oldLength != newLength) {
        return false;
      }
      for(int i=0; i<oldLength; i++) {
        if (oldBuffer.charAt(oldStart+i) != newBuffer.charAt(newStart+i)) {
          return false;
        }
      }
    }
    oldTextLexer.advance();
    newTextLexer.advance();
  }
}
项目:consulo-java    文件:JavadocParser.java   
private static void parseSimpleTagValue(@NotNull final PsiBuilder builder, final boolean parameter)
{
    final PsiBuilder.Marker tagValue = builder.mark();
    while(TAG_VALUES_SET.contains(getTokenType(builder)))
    {
        builder.advanceLexer();
    }
    tagValue.done(parameter ? JavaDocElementType.DOC_PARAMETER_REF : JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
}
项目:consulo-java    文件:PsiInlineDocTagImpl.java   
@Override
public PsiDocComment getContainingComment()
{
    ASTNode scope = getTreeParent();
    while(scope.getElementType() != JavaDocElementType.DOC_COMMENT)
    {
        scope = scope.getTreeParent();
    }
    return (PsiDocComment) SourceTreeToPsiMap.treeElementToPsi(scope);
}
项目:consulo-java    文件:JavaDocInfoGenerator.java   
/**
 * Finds doc comment immediately preceding package statement
 */
@Nullable
private static ASTNode findRelevantCommentNode(@NotNull ASTNode fileNode)
{
    ASTNode node = fileNode.findChildByType(JavaElementType.PACKAGE_STATEMENT);
    if(node == null)
    {
        node = fileNode.getLastChildNode();
    }
    while(node != null && node.getElementType() != JavaDocElementType.DOC_COMMENT)
    {
        node = node.getTreePrev();
    }
    return node;
}
项目:consulo-java    文件:AbstractJavaBlock.java   
@Override
@NotNull
public ChildAttributes getChildAttributes(final int newChildIndex)
{
    if(myUseChildAttributes)
    {
        return new ChildAttributes(myChildIndent, myChildAlignment);
    }
    if(isAfter(newChildIndex, new IElementType[]{JavaDocElementType.DOC_COMMENT}))
    {
        return new ChildAttributes(Indent.getNoneIndent(), myChildAlignment);
    }
    return super.getChildAttributes(newChildIndex);
}
项目:consulo-java    文件:JavaSpacePropertyProcessor.java   
@Override
public void visitDocTag(PsiDocTag tag)
{
    if(myType1 == JavaDocTokenType.DOC_TAG_NAME && myType2 == JavaDocElementType.DOC_TAG_VALUE_ELEMENT)
    {
        myResult = Spacing.createSpacing(1, 1, 0, false, 0);
    }
}