當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。