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


Java TokenSet类代码示例

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


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

示例1: isComment

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
private boolean isComment(int offset) {
  final HighlighterIterator it = myEditor.getHighlighter().createIterator(offset);
  IElementType tokenType = it.getTokenType();
  Language language = tokenType.getLanguage();
  TokenSet comments = myComments.get(language);
  if (comments == null) {
    ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
    if (definition != null) {
      comments = definition.getCommentTokens();
    }
    if (comments == null) {
      return false;
    }
    else {
      myComments.put(language, comments);
    }
  }
  return comments.contains(tokenType);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:IndentsPass.java

示例2: getStubOrPsiChildren

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
/**
 * @return children of specified type, taken from stubs (if this element is currently stub-based) or AST (otherwise).
 */
public <Psi extends PsiElement> Psi[] getStubOrPsiChildren(TokenSet filter, ArrayFactory<Psi> f) {
  T stub = myStub;
  if (stub != null) {
    //noinspection unchecked
    return (Psi[])stub.getChildrenByType(filter, f);
  }
  else {
    final ASTNode[] nodes = getNode().getChildren(filter);
    Psi[] psiElements = f.create(nodes.length);
    for (int i = 0; i < nodes.length; i++) {
      //noinspection unchecked
      psiElements[i] = (Psi)nodes[i].getPsi();
    }
    return psiElements;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StubBasedPsiElementBase.java

示例3: parseEnumBody

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
private static IElementType parseEnumBody(@NotNull PsiBuilder builder,
                                          @NotNull String enumName,
                                          @NotNull GroovyParser parser) {
  PsiBuilder.Marker ebMarker = builder.mark();

  if (!ParserUtils.getToken(builder, GroovyTokenTypes.mLCURLY)) {
    ebMarker.rollbackTo();
    return GroovyElementTypes.WRONGWAY;
  }

  ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);

  if (EnumConstant.parseConstantList(builder, parser)) {
    if (!ParserUtils.lookAhead(builder, GroovyTokenTypes.mRCURLY)) {
      ParserUtils.getToken(builder, TokenSet.create(GroovyTokenTypes.mNLS, GroovyTokenTypes.mSEMI), GroovyBundle.message("separator.or.rcurly.expected"));
    }
  }

  parseMembers(builder, enumName, parser, false);

  ParserUtils.getToken(builder, GroovyTokenTypes.mRCURLY, GroovyBundle.message("rcurly.expected"));

  ebMarker.done(GroovyElementTypes.ENUM_BODY);
  return GroovyElementTypes.ENUM_BODY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:TypeDefinition.java

示例4: isInsideStringLiteral

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
private static boolean isInsideStringLiteral(@NotNull Editor editor, @NotNull PsiFile file) {
  int offset = editor.getCaretModel().getOffset();
  PsiElement element = file.findElementAt(offset);
  if (element == null) return false;
  final ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(element.getLanguage());
  if (definition != null) {
    final TokenSet stringLiteralElements = definition.getStringLiteralElements();
    final ASTNode node = element.getNode();
    if (node == null) return false;
    final IElementType elementType = node.getElementType();
    if (stringLiteralElements.contains(elementType)) {
      return true;
    }
    PsiElement parent = element.getParent();
    if (parent != null) {
      ASTNode parentNode = parent.getNode();
      if (parentNode != null && stringLiteralElements.contains(parentNode.getElementType())) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:TypedHandler.java

示例5: checkNodeAndSiblings

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
@Nullable
private static ASTNode checkNodeAndSiblings(@Nullable ASTNode node, TokenSet tokens, ArrayList<FoldingDescriptor> regions, Document document) {
  if (node != null && tokens.contains(node.getElementType())) {
    final ASTNode start = node;
    ASTNode end = start;

    node = node.getTreeNext();
    if (node != null) {
      do {
        end = node;
        node = node.getTreeNext();
      } while (node != null && tokens.contains(node.getElementType()));
    }
    if (end != start) {
      while (end.getPsi() instanceof PsiWhiteSpace) {
        end = end.getTreePrev();
      }
      if (isOnDifferentLine(start, end, document)) {
        regions.add(new FoldingDescriptor(start, new TextRange(start.getStartOffset(), end.getTextRange().getEndOffset())));
      }
    }
  }
  return node;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:RncFoldingBuilder.java

示例6: doApply

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
@Override
public void doApply(@NotNull Editor editor, @NotNull PySmartEnterProcessor processor, @NotNull PyConditionalStatementPart statementPart)
  throws IncorrectOperationException {
  final PyExpression condition = statementPart.getCondition();
  final Document document = editor.getDocument();
  final PsiElement colon = PyPsiUtils.getFirstChildOfType(statementPart, PyTokenTypes.COLON);
  if (colon == null) {
    if (condition != null) {
      final PsiElement firstNonComment = PyPsiUtils.getNextNonCommentSibling(condition.getNextSibling(), false);
      if (firstNonComment != null && !":".equals(firstNonComment.getNode().getText())) {
        document.insertString(firstNonComment.getTextRange().getEndOffset(), ":");
      }
    }
    else {
      final TokenSet keywords = TokenSet.create(PyTokenTypes.IF_KEYWORD, PyTokenTypes.ELIF_KEYWORD, PyTokenTypes.WHILE_KEYWORD);
      final PsiElement keywordToken = PyPsiUtils.getChildByFilter(statementPart,
                                                                  keywords, 0);
      final int offset = sure(keywordToken).getTextRange().getEndOffset();
      document.insertString(offset, " :");
      processor.registerUnresolvedError(offset + 1);
    }
  }
  else if (condition == null) {
    processor.registerUnresolvedError(colon.getTextRange().getStartOffset());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:PyConditionalStatementPartFixer.java

示例7: acceptInput

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
@Override
public boolean acceptInput(@NotNull final VirtualFile file) {
  if (!file.isInLocalFileSystem()) {
    return false; // do not index TODOs in library sources
  }

  final FileType fileType = file.getFileType();

  if (fileType instanceof LanguageFileType) {
    final Language lang = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
    final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens() : null;
    return commentTokens != null;
  }

  return PlatformIdTableBuilding.isTodoIndexerRegistered(fileType) ||
         fileType instanceof CustomSyntaxTableFileType;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:TodoIndex.java

示例8: getWordsScanner

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
@Nullable
@Override
public WordsScanner getWordsScanner() {
    return new DefaultWordsScanner(
            new TSLexerAdapter(),
            TokenSet.create(TSTypes.ID),
            TokenSet.create(TSTypes.COMMENT),
            TokenSet.EMPTY
    );
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:11,代码来源:TSFindUsagesProvider.java

示例9: getWordsScanner

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
@Nullable
@Override
public WordsScanner getWordsScanner() {
  return new DefaultWordsScanner(new AppleScriptLexerAdapter(),
          TokenSet.create(AppleScriptTypes.IDENTIFIER),
          TokenSet.create(AppleScriptTypes.COMMENT),
          TokenSet.create(AppleScriptTypes.STRING_LITERAL));
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:9,代码来源:AppleScriptFindUsagesProvider.java

示例10: getWordsScanner

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
@Nullable
@Override
public WordsScanner getWordsScanner() {
  return new DefaultWordsScanner(
      new SoyLexer(),
      TokenSet.create(SoyTypes.IDENTIFIER_WORD),
      TokenSet.create(SoyTypes.COMMENT_BLOCK),
      TokenSet.EMPTY);
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:10,代码来源:SoyFindUsagesProvider.java

示例11: annotate

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
  if (psiElement instanceof TagElement) {
    TagElement tagElement = (TagElement) psiElement;

    TokenSet allowedRBraces = SoyTokenTypes.RIGHT_BRACES;
    if (mustCloseRBraceTags.contains(tagElement.getClass())) {
      allowedRBraces = TokenSet.andNot(allowedRBraces, SoyTokenTypes.SLASH_R_BRACES);
    } else if (mustCloseSlashRBraceTags.contains(tagElement.getClass())) {
      allowedRBraces = TokenSet.andSet(allowedRBraces, SoyTokenTypes.SLASH_R_BRACES);
    }

    if (tagElement.isDoubleBraced()) {
      allowedRBraces = TokenSet.andSet(allowedRBraces, SoyTokenTypes.DOUBLE_BRACES);
    } else {
      allowedRBraces = TokenSet.andNot(allowedRBraces, SoyTokenTypes.DOUBLE_BRACES);
    }

    if (!allowedRBraces.contains(tagElement.getClosingBraceType())) {
      annotationHolder.createErrorAnnotation(tagElement, "Must close by " +
          Stream.of(allowedRBraces.getTypes())
              .map(SoyTokenTypes.BRACE_TYPE_TO_STRING::get)
              .sorted()
              .collect(Collectors.joining(" or ")));
    }
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:28,代码来源:ClosingBraceSanityAnnotator.java

示例12: createSpaceBuilder

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
private static SpacingBuilder createSpaceBuilder(final CodeStyleSettings settings) {

        return new SpacingBuilder(settings, FlexibleSearchLanguage.getInstance())
            .after(FlexibleSearchTypes.COMP_OP)
            .spaceIf(true)

            .before(FlexibleSearchTypes.COMP_OP)
            .spaceIf(true)

            .after(FlexibleSearchTypes.LEFT_DOUBLE_BRACE)
            .spaceIf(true)

            .before(FlexibleSearchTypes.RIGHT_DOUBLE_BRACE)
            .spaceIf(true)

            .before(FlexibleSearchTypes.LEFT_BRACE)
            .spaceIf(true)

            .after(FlexibleSearchTypes.RIGHT_BRACE)
            .spaceIf(true)

            .before(FlexibleSearchTypes.LEFT_PAREN)
            .spaceIf(true)

            .after(FlexibleSearchTypes.RIGHT_PAREN)
            .spaceIf(true)

            .around(TokenSet.create(FlexibleSearchTypes.WHERE, FlexibleSearchTypes.WHERE_CLAUSE))
            .spaceIf(true)
            ;
    }
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:32,代码来源:FlexibleSearchFormattingModelBuilder.java

示例13: getWordsScanner

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
@Nullable
@Override
public WordsScanner getWordsScanner() {
    return new DefaultWordsScanner(
        new ImpexLexerAdapter(),
        orSet(
            create(ImpexTypes.MACRO_NAME_DECLARATION),
            create(ImpexTypes.MACRO_DECLARATION),
            create(ImpexTypes.MACRO_USAGE)
        ),
        create(ImpexTypes.COMMENT),
        TokenSet.ANY
    );
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:15,代码来源:ImpexFindUsagesProvider.java

示例14: getDocuments

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
public List<YAMLDocument> getDocuments() {
    final ArrayList<YAMLDocument> result = new ArrayList<>();
    for (ASTNode node : getNode().getChildren(TokenSet.create(YAMLElementTypes.DOCUMENT))) {
        result.add((YAMLDocument) node.getPsi());
    }
    return result;
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:8,代码来源:CoffigYamlFileImpl.java

示例15: getWordsScanner

import com.intellij.psi.tree.TokenSet; //导入依赖的package包/类
@Nullable
@Override
public WordsScanner getWordsScanner() {
    return new DefaultWordsScanner(new YAMLFlexLexer(),
            TokenSet.create(YAMLTokenTypes.SCALAR_KEY),
            TokenSet.create(YAMLTokenTypes.COMMENT),
            TokenSet.create(YAMLTokenTypes.SCALAR_TEXT, YAMLTokenTypes.SCALAR_DSTRING, YAMLTokenTypes.SCALAR_STRING));
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:9,代码来源:CoffigFindUsagesProvider.java


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