Java 类com.intellij.psi.JavaDocTokenType 实例源码

项目:intellij-ce-playground    文件:DocCommentBlock.java   
@Override
protected List<Block> buildChildren() {
  final ArrayList<Block> result = new ArrayList<Block>();

  ASTNode child = myNode.getFirstChildNode();
  while (child != null) {
    if (child.getElementType() == JavaDocTokenType.DOC_COMMENT_START) {
      result.add(createJavaBlock(child, mySettings, myJavaSettings, Indent.getNoneIndent(), null, AlignmentStrategy.getNullStrategy()));
    } else if (!FormatterUtil.containsWhiteSpacesOnly(child) && !child.getText().trim().isEmpty()){
      result.add(createJavaBlock(child, mySettings, myJavaSettings, Indent.getSpaceIndent(1), null, AlignmentStrategy.getNullStrategy()));
    }
    child = child.getTreeNext();
  }
  return result;

}
项目:intellij-ce-playground    文件:HtmlTagCanBeJavadocTagInspection.java   
@Override
public void visitDocToken(PsiDocToken token) {
  super.visitDocToken(token);
  final IElementType tokenType = token.getTokenType();
  if (!JavaDocTokenType.DOC_COMMENT_DATA.equals(tokenType)) {
    return;
  }
  @NonNls final String text = token.getText();
  int startIndex = 0;
  while (true) {
    startIndex = StringUtil.indexOfIgnoreCase(text, "<code>", startIndex);
    if (startIndex < 0) {
      return;
    }
    if (hasMatchingCloseTag(token, startIndex + 6)) {
      registerErrorAtOffset(token, startIndex, 6);
    }
    startIndex++;
  }
}
项目: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    文件:DocCommentBlock.java   
@Override
protected List<Block> buildChildren() {
  final ArrayList<Block> result = new ArrayList<Block>();

  ASTNode child = myNode.getFirstChildNode();
  while (child != null) {
    if (child.getElementType() == JavaDocTokenType.DOC_COMMENT_START) {
      result.add(createJavaBlock(child, mySettings, Indent.getNoneIndent(), null, AlignmentStrategy.getNullStrategy()));
    } else if (!FormatterUtil.containsWhiteSpacesOnly(child) && child.getText().trim().length() > 0){
      result.add(createJavaBlock(child, mySettings, Indent.getSpaceIndent(1), null, AlignmentStrategy.getNullStrategy()));
    }
    child = child.getTreeNext();
  }
  return result;

}
项目: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);
}
项目:tools-idea    文件:HtmlTagCanBeJavadocTagInspection.java   
@Override
public void visitDocToken(PsiDocToken token) {
  super.visitDocToken(token);
  if (!PsiUtil.isLanguageLevel5OrHigher(token)) {
    return;
  }
  final IElementType tokenType = token.getTokenType();
  if (!JavaDocTokenType.DOC_COMMENT_DATA.equals(tokenType)) {
    return;
  }
  @NonNls final String text = token.getText();
  int startIndex = 0;
  while (true) {
    startIndex = text.indexOf("<code>", startIndex);
    if (startIndex < 0) {
      return;
    }
    if (hasMatchingCloseTag(token, startIndex + 6)) {
      registerErrorAtOffset(token, startIndex, 6, Integer.valueOf(startIndex));
    }
    startIndex++;
  }
}
项目:consulo-java    文件:JavadocParser.java   
public static void parseDocCommentText(@NotNull final PsiBuilder builder)
{
    builder.enforceCommentTokens(SKIP_TOKENS);

    while(!builder.eof())
    {
        final IElementType tokenType = getTokenType(builder);
        if(tokenType == JavaDocTokenType.DOC_TAG_NAME)
        {
            parseTag(builder);
        }
        else
        {
            parseDataItem(builder, null, false);
        }
    }
}
项目: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    文件:RecordUtil.java   
public static boolean isDeprecatedByDocComment(@NotNull LighterAST tree, @NotNull LighterASTNode comment)
{
    String text = LightTreeUtil.toFilteredString(tree, comment, null);
    if(text.contains(DEPRECATED_TAG))
    {
        JavaDocLexer lexer = new JavaDocLexer(LanguageLevel.HIGHEST);
        lexer.start(text);
        IElementType token;
        while((token = lexer.getTokenType()) != null)
        {
            if(token == JavaDocTokenType.DOC_TAG_NAME && DEPRECATED_TAG.equals(lexer.getTokenText()))
            {
                return true;
            }
            lexer.advance();
        }
    }

    return false;
}
项目:consulo-java    文件:JavadocCompletionConfidence.java   
@NotNull
@Override
public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset)
{
    if(psiElement().inside(PsiDocTag.class).accepts(contextElement))
    {
        if(findJavaReference(psiFile, offset - 1) != null)
        {
            return ThreeState.NO;
        }
        if(PlatformPatterns.psiElement(JavaDocTokenType.DOC_TAG_NAME).accepts(contextElement))
        {
            return ThreeState.NO;
        }
        if(contextElement.textMatches("#"))
        {
            return ThreeState.NO;
        }
    }
    return super.shouldSkipAutopopup(contextElement, psiFile, offset);
}
项目:consulo-java    文件:DocCommentBlock.java   
@Override
protected List<Block> buildChildren()
{
    final ArrayList<Block> result = new ArrayList<>();

    ASTNode child = myNode.getFirstChildNode();
    while(child != null)
    {
        if(child.getElementType() == JavaDocTokenType.DOC_COMMENT_START)
        {
            result.add(createJavaBlock(child, mySettings, myJavaSettings, Indent.getNoneIndent(), null, AlignmentStrategy.getNullStrategy()));
        }
        else if(!FormatterUtil.containsWhiteSpacesOnly(child) && !child.getText().trim().isEmpty())
        {
            result.add(createJavaBlock(child, mySettings, myJavaSettings, Indent.getSpaceIndent(1), null, AlignmentStrategy.getNullStrategy()));
        }
        child = child.getTreeNext();
    }
    return result;

}
项目:consulo-java    文件:ParamDocTagInfo.java   
@Override
public String checkTagValue(PsiDocTagValue value) {
  if (value == null) return JavaErrorMessages.message("javadoc.param.tag.parameter.name.expected");
  final ASTNode firstChildNode = value.getNode().getFirstChildNode();
  if (firstChildNode != null &&
      firstChildNode.getElementType().equals(JavaDocTokenType.DOC_TAG_VALUE_LT)) {
    if (value.getNode().findChildByType(JavaDocTokenType.DOC_TAG_VALUE_TOKEN) == null) {
      return JavaErrorMessages.message("javadoc.param.tag.type.parameter.name.expected");
    }

    if (value.getNode().findChildByType(JavaDocTokenType.DOC_TAG_VALUE_GT) == null) {
      return JavaErrorMessages.message("javadoc.param.tag.type.parameter.gt.expected");
    }
  }
  return null;
}
项目: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);
}
项目:consulo-java    文件:HtmlTagCanBeJavadocTagInspection.java   
@Override
public void visitDocToken(PsiDocToken token) {
  super.visitDocToken(token);
  if (!PsiUtil.isLanguageLevel5OrHigher(token)) {
    return;
  }
  final IElementType tokenType = token.getTokenType();
  if (!JavaDocTokenType.DOC_COMMENT_DATA.equals(tokenType)) {
    return;
  }
  @NonNls final String text = token.getText();
  int startIndex = 0;
  while (true) {
    startIndex = text.indexOf("<code>", startIndex);
    if (startIndex < 0) {
      return;
    }
    if (hasMatchingCloseTag(token, startIndex + 6)) {
      registerErrorAtOffset(token, startIndex, 6, Integer.valueOf(startIndex));
    }
    startIndex++;
  }
}
项目:intellij-ce-playground    文件:JavadocParser.java   
public static void parseDocCommentText(@NotNull final PsiBuilder builder) {
  builder.enforceCommentTokens(SKIP_TOKENS);

  while (!builder.eof()) {
    final IElementType tokenType = getTokenType(builder);
    if (tokenType == JavaDocTokenType.DOC_TAG_NAME) {
      parseTag(builder);
    }
    else {
      parseDataItem(builder, null, false);
    }
  }
}
项目: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   
@Nullable
private static IElementType getTokenType(@NotNull final PsiBuilder builder) {
  IElementType tokenType;
  while ((tokenType = builder.getTokenType()) == JavaDocTokenType.DOC_SPACE) {
    builder.remapCurrentToken(TokenType.WHITE_SPACE);
    builder.advanceLexer();
  }
  return tokenType;
}
项目:intellij-ce-playground    文件:PsiDocTokenImpl.java   
@NotNull
@Override
public PsiReference[] getReferences() {
  if (getTokenType() == JavaDocTokenType.DOC_COMMENT_DATA) {
    return ReferenceProvidersRegistry.getReferencesFromProviders(this, PsiDocToken.class);
  }
  return super.getReferences();
}
项目:intellij-ce-playground    文件:CorePsiDocTagValueImpl.java   
@Override
public int getChildRole(ASTNode child) {
  if (child.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_COMMA) {
    return ChildRole.COMMA;
  }

  return super.getChildRole(child);
}
项目: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    文件:DocDataHandler.java   
private static String getTextFromNode(final PsiElement node, String text1) {
  PsiElement nextSibling = node.getNextSibling();
  if (nextSibling instanceof PsiDocTagValue) {
    text1 += nextSibling.getText();

    nextSibling = nextSibling.getNextSibling();
    if (nextSibling instanceof PsiDocToken && ((PsiDocToken)nextSibling).getTokenType() == JavaDocTokenType.DOC_COMMENT_DATA) {
      text1 += nextSibling.getText();
    }
  }
  return text1;
}
项目:intellij-ce-playground    文件:DocTagSelectioner.java   
public static TextRange getDocTagRange(PsiDocTag e, CharSequence documentText, int minOffset) {
  TextRange range = e.getTextRange();

  int endOffset = range.getEndOffset();
  int startOffset = range.getStartOffset();

  PsiElement[] children = e.getChildren();

  for (int i = children.length - 1; i >= 0; i--) {
    PsiElement child = children[i];

    int childStartOffset = child.getTextRange().getStartOffset();

    if (childStartOffset <= minOffset) {
      break;
    }

    if (child instanceof PsiDocToken) {
      PsiDocToken token = (PsiDocToken)child;

      IElementType type = token.getTokenType();
      char[] chars = token.textToCharArray();
      int shift = CharArrayUtil.shiftForward(chars, 0, " \t\n\r");

      if (shift != chars.length && type != JavaDocTokenType.DOC_COMMENT_LEADING_ASTERISKS) {
        break;
      }
    }
    else if (!(child instanceof PsiWhiteSpace)) {
      break;
    }

    endOffset = Math.min(childStartOffset, endOffset);
  }

  startOffset = CharArrayUtil.shiftBackward(documentText, startOffset - 1, "* \t") + 1;

  return new TextRange(startOffset, endOffset);
}
项目:tools-idea    文件:JavadocParser.java   
public static void parseDocCommentText(@NotNull final PsiBuilder builder) {
  builder.enforceCommentTokens(SKIP_TOKENS);

  while (!builder.eof()) {
    final IElementType tokenType = getTokenType(builder);
    if (tokenType == JavaDocTokenType.DOC_TAG_NAME) {
      parseTag(builder);
    }
    else {
      parseDataItem(builder, null, false);
    }
  }
}
项目: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   
@Nullable
private static IElementType getTokenType(@NotNull final PsiBuilder builder) {
  IElementType tokenType;
  while ((tokenType = builder.getTokenType()) == JavaDocTokenType.DOC_SPACE) {
    builder.remapCurrentToken(TokenType.WHITE_SPACE);
    builder.advanceLexer();
  }
  return tokenType;
}
项目:tools-idea    文件:CorePsiDocTagValueImpl.java   
@Override
public int getChildRole(ASTNode child) {
  if (child.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_COMMA) {
    return ChildRole.COMMA;
  }

  return super.getChildRole(child);
}
项目:tools-idea    文件:DocTagSelectioner.java   
public static TextRange getDocTagRange(PsiDocTag e, CharSequence documentText, int minOffset) {
  TextRange range = e.getTextRange();

  int endOffset = range.getEndOffset();
  int startOffset = range.getStartOffset();

  PsiElement[] children = e.getChildren();

  for (int i = children.length - 1; i >= 0; i--) {
    PsiElement child = children[i];

    int childStartOffset = child.getTextRange().getStartOffset();

    if (childStartOffset <= minOffset) {
      break;
    }

    if (child instanceof PsiDocToken) {
      PsiDocToken token = (PsiDocToken)child;

      IElementType type = token.getTokenType();
      char[] chars = token.textToCharArray();
      int shift = CharArrayUtil.shiftForward(chars, 0, " \t\n\r");

      if (shift != chars.length && type != JavaDocTokenType.DOC_COMMENT_LEADING_ASTERISKS) {
        break;
      }
    }
    else if (!(child instanceof PsiWhiteSpace)) {
      break;
    }

    endOffset = Math.min(childStartOffset, endOffset);
  }

  startOffset = CharArrayUtil.shiftBackward(documentText, startOffset - 1, "* \t") + 1;

  return new TextRange(startOffset, endOffset);
}
项目:tools-idea    文件:JavaIndexPatternBuilder.java   
@Override
@Nullable
public TokenSet getCommentTokenSet(final PsiFile file) {
  if (file instanceof PsiJavaFile && !(file instanceof JspFile)) {
    return TokenSet.orSet(StdTokenSets.COMMENT_BIT_SET, XML_COMMENT_BIT_SET, JavaDocTokenType.ALL_JAVADOC_TOKENS, XML_DATA_CHARS);
  }
  return null;
}
项目:tools-idea    文件:UnnecessaryInheritDocInspection.java   
@Override
public void visitDocTag(PsiDocTag tag) {
  if (!(tag instanceof PsiInlineDocTag)) {
    return;
  }
  @NonNls final String name = tag.getName();
  if (!"inheritDoc".equals(name)) {
    return;
  }
  final PsiDocComment docComment = tag.getContainingComment();
  if (docComment == null) {
    return;
  }
  final PsiDocToken[] docTokens = PsiTreeUtil.getChildrenOfType(
    docComment, PsiDocToken.class);
  if (docTokens == null) {
    return;
  }
  for (PsiDocToken docToken : docTokens) {
    final IElementType tokenType = docToken.getTokenType();
    if (!JavaDocTokenType.DOC_COMMENT_DATA.equals(tokenType)) {
      continue;
    }
    if (!StringUtil.isEmptyOrSpaces(docToken.getText())) {
      return;
    }
  }
  registerError(tag);
}
项目:consulo-java    文件:JavadocParser.java   
@Nullable
private static IElementType getTokenType(@NotNull final PsiBuilder builder)
{
    IElementType tokenType;
    while((tokenType = builder.getTokenType()) == JavaDocTokenType.DOC_SPACE)
    {
        builder.remapCurrentToken(TokenType.WHITE_SPACE);
        builder.advanceLexer();
    }
    return tokenType;
}
项目:consulo-java    文件:JavadocParser.java   
private static void remapAndAdvance(@NotNull final PsiBuilder builder)
{
    if(INLINE_TAG_BORDERS_SET.contains(builder.getTokenType()) && getBraceScope(builder) != 1)
    {
        builder.remapCurrentToken(JavaDocTokenType.DOC_COMMENT_DATA);
    }
    builder.advanceLexer();
}
项目:consulo-java    文件:CorePsiDocTagValueImpl.java   
@Override
public int getChildRole(ASTNode child) {
  if (child.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_COMMA) {
    return ChildRole.COMMA;
  }

  return super.getChildRole(child);
}
项目:consulo-java    文件:JavaIndexPatternBuilder.java   
@Override
@Nullable
public TokenSet getCommentTokenSet(final PsiFile file) {
  if (file instanceof PsiJavaFile /*&& !(file instanceof JspFile)*/) {
    return TokenSet.orSet(StdTokenSets.COMMENT_BIT_SET, XML_COMMENT_BIT_SET, JavaDocTokenType.ALL_JAVADOC_TOKENS, XML_DATA_CHARS);
  }
  return null;
}
项目:consulo-java    文件:UnnecessaryInheritDocInspection.java   
@Override
public void visitDocTag(PsiDocTag tag) {
  if (!(tag instanceof PsiInlineDocTag)) {
    return;
  }
  @NonNls final String name = tag.getName();
  if (!"inheritDoc".equals(name)) {
    return;
  }
  final PsiDocComment docComment = tag.getContainingComment();
  if (docComment == null) {
    return;
  }
  final PsiDocToken[] docTokens = PsiTreeUtil.getChildrenOfType(
    docComment, PsiDocToken.class);
  if (docTokens == null) {
    return;
  }
  for (PsiDocToken docToken : docTokens) {
    final IElementType tokenType = docToken.getTokenType();
    if (!JavaDocTokenType.DOC_COMMENT_DATA.equals(tokenType)) {
      continue;
    }
    if (!StringUtil.isEmptyOrSpaces(docToken.getText())) {
      return;
    }
  }
  registerError(tag);
}
项目:intellij-ce-playground    文件:JavadocParser.java   
private static void parseDataItem(@NotNull final PsiBuilder builder, @Nullable final String tagName, final boolean isInline) {
  IElementType tokenType = getTokenType(builder);
  if (tokenType == JavaDocTokenType.DOC_INLINE_TAG_START) {
    int braceScope = getBraceScope(builder);
    if (braceScope > 0) {
      setBraceScope(builder, braceScope + 1);
      builder.remapCurrentToken(JavaDocTokenType.DOC_COMMENT_DATA);
      builder.advanceLexer();
      return;
    }

    final PsiBuilder.Marker tag = builder.mark();
    builder.advanceLexer();

    tokenType = getTokenType(builder);
    if (tokenType != JavaDocTokenType.DOC_TAG_NAME && tokenType != JavaDocTokenType.DOC_COMMENT_BAD_CHARACTER) {
      tag.rollbackTo();
      builder.remapCurrentToken(JavaDocTokenType.DOC_COMMENT_DATA);
      builder.advanceLexer();
      return;
    }

    setBraceScope(builder, braceScope + 1);
    String inlineTagName = "";

    while (true) {
      tokenType = getTokenType(builder);
      if (tokenType == JavaDocTokenType.DOC_TAG_NAME) {
        inlineTagName = builder.getTokenText();
      }
      else if (tokenType == null || tokenType == JavaDocTokenType.DOC_COMMENT_END) {
        break;
      }

      parseDataItem(builder, inlineTagName, true);
      if (tokenType == JavaDocTokenType.DOC_INLINE_TAG_END) {
        braceScope = getBraceScope(builder);
        if (braceScope > 0) setBraceScope(builder, --braceScope);
        if (braceScope == 0) break;
      }
    }

    tag.done(JavaDocElementType.DOC_INLINE_TAG);
  }
  else if (TAG_VALUES_SET.contains(tokenType)) {
    if (SEE_TAG.equals(tagName) && !isInline ||
        LINK_TAG.equals(tagName) && isInline) {
      parseSeeTagValue(builder, false);
    }
    else {
      if (JavaParserUtil.getLanguageLevel(builder).isAtLeast(LanguageLevel.JDK_1_4) && LINK_PLAIN_TAG.equals(tagName) && isInline) {
        parseSeeTagValue(builder, false);
      }
      else if (!isInline && (THROWS_TAG.equals(tagName) || EXCEPTION_TAG.equals(tagName))) {
        final PsiBuilder.Marker tagValue = builder.mark();
        builder.remapCurrentToken(JavaDocElementType.DOC_REFERENCE_HOLDER);
        builder.advanceLexer();
        tagValue.done(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
      }
      else if (!isInline && tagName != null && tagName.equals(PARAM_TAG)) {
        parseSimpleTagValue(builder, true);
      }
      else {
        if (JavaParserUtil.getLanguageLevel(builder).isAtLeast(LanguageLevel.JDK_1_5) && VALUE_TAG.equals(tagName) && isInline) {
          parseSeeTagValue(builder, true);
        }
        else {
          parseSimpleTagValue(builder, false);
        }
      }
    }
  }
  else {
    remapAndAdvance(builder);
  }
}
项目:intellij-ce-playground    文件:JavadocParser.java   
private static void parseMethodRef(@NotNull final PsiBuilder builder, @NotNull final PsiBuilder.Marker refStart) {
  if (getTokenType(builder) == JavaDocTokenType.DOC_TAG_VALUE_SHARP_TOKEN) {
    builder.advanceLexer();
  }
  if (getTokenType(builder) != JavaDocTokenType.DOC_TAG_VALUE_TOKEN) {
    refStart.done(JavaDocElementType.DOC_METHOD_OR_FIELD_REF);
    return;
  }
  builder.advanceLexer();

  if (getTokenType(builder) == JavaDocTokenType.DOC_TAG_VALUE_LPAREN) {
    builder.advanceLexer();

    final PsiBuilder.Marker subValue = builder.mark();

    IElementType tokenType;
    while (TAG_VALUES_SET.contains(tokenType = getTokenType(builder))) {
      if (tokenType == JavaDocTokenType.DOC_TAG_VALUE_TOKEN) {
        builder.remapCurrentToken(JavaDocElementType.DOC_TYPE_HOLDER);
        builder.advanceLexer();

        while (TAG_VALUES_SET.contains(tokenType = getTokenType(builder)) &&
               tokenType != JavaDocTokenType.DOC_TAG_VALUE_COMMA && tokenType != JavaDocTokenType.DOC_TAG_VALUE_RPAREN) {
          builder.advanceLexer();
        }
      }
      else if (tokenType == JavaDocTokenType.DOC_TAG_VALUE_RPAREN) {
        subValue.done(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
        builder.advanceLexer();
        refStart.done(JavaDocElementType.DOC_METHOD_OR_FIELD_REF);
        return;
      }
      else {
        builder.advanceLexer();
      }
    }

    subValue.done(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
  }

  refStart.done(JavaDocElementType.DOC_METHOD_OR_FIELD_REF);
}
项目:intellij-ce-playground    文件:JavadocParser.java   
private static void remapAndAdvance(@NotNull final PsiBuilder builder) {
  if (INLINE_TAG_BORDERS_SET.contains(builder.getTokenType()) && getBraceScope(builder) != 1) {
    builder.remapCurrentToken(JavaDocTokenType.DOC_COMMENT_DATA);
  }
  builder.advanceLexer();
}
项目:intellij-ce-playground    文件:JavaCommenter.java   
@Override
public boolean isDocumentationCommentText(final PsiElement element) {
  if (element == null) return false;
  final ASTNode node = element.getNode();
  return node != null && (node.getElementType() == JavaDocTokenType.DOC_COMMENT_DATA || node.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_TOKEN);
}