Java 类com.intellij.lang.BracePair 实例源码

项目:AppleScript-IDEA    文件:AppleScriptPairedBraceMatcher.java   
@Override
public boolean isRBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
  BracePair pair = findPair(false, iterator, fileText, fileType);
  if (pair == null) return false;
  if (pair.getRightBraceType() != AppleScriptTypes.END)
    return super.isRBraceToken(iterator, fileText, fileType);//true;

  boolean result = false;
  int count = 0;
  while (true) {
    iterator.retreat();
    count++;
    if (iterator.atEnd()) break;
    IElementType eType = iterator.getTokenType();
    if (eType == AppleScriptTypes.NLS || eType == AppleScriptTypes.BLOCK_BODY)
      result = true;
    else break;
  }
  while (count-- > 0) iterator.advance();
  return result;
}
项目:intellij-ce-playground    文件:PairedBraceMatcherAdapter.java   
@Override
@NotNull
public List<IElementType> getOppositeBraceTokenTypes(@NotNull IElementType type) {
  List<IElementType> result = null;

  for (BracePair pair : myMatcher.getPairs()) {
    IElementType match = null;

    if (type == pair.getRightBraceType()) match = pair.getLeftBraceType();
    if (type == pair.getLeftBraceType()) match = pair.getRightBraceType();

    if (match != null) {
      if (result == null) result = new ArrayList<IElementType>(2);
      result.add(match);
    }
  }

  return result != null ? result : Collections.<IElementType>emptyList();
}
项目:intellij-ce-playground    文件:XmlBraceMatcher.java   
@Override
public int getBraceTokenGroupId(IElementType tokenType) {
  final Language l = tokenType.getLanguage();
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(l);

  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getLeftBraceType() == tokenType || pair.getRightBraceType() == tokenType ) {
        return l.hashCode();
      }
    }
  }
  if (tokenType instanceof IXmlLeafElementType) {
    return tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER || tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER
           ? XML_VALUE_DELIMITER_GROUP
           : XML_TAG_TOKEN_GROUP;
  }
  else{
    return BraceMatchingUtil.UNDEFINED_TOKEN_GROUP;
  }
}
项目:intellij-ce-playground    文件:XmlBraceMatcher.java   
@Override
public boolean isStructuralBrace(HighlighterIterator iterator,CharSequence text, FileType fileType) {
  IElementType tokenType = iterator.getTokenType();

  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage());
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if ((pair.getLeftBraceType() == tokenType || pair.getRightBraceType() == tokenType) &&
          pair.isStructural()) return true;
    }
  }
  if (fileType instanceof XmlLikeFileType) {
    return isXmlStructuralBrace(iterator, text, fileType, tokenType);
  }
  return false;
}
项目:tools-idea    文件:PairedBraceMatcherAdapter.java   
@Override
@NotNull
public List<IElementType> getOppositeBraceTokenTypes(@NotNull IElementType type) {
  List<IElementType> result = null;

  for (BracePair pair : myMatcher.getPairs()) {
    IElementType match = null;

    if (type == pair.getRightBraceType()) match = pair.getLeftBraceType();
    if (type == pair.getLeftBraceType()) match = pair.getRightBraceType();

    if (match != null) {
      if (result == null) result = new ArrayList<IElementType>(2);
      result.add(match);
    }
  }

  return result != null ? result : Collections.<IElementType>emptyList();
}
项目:tools-idea    文件:XmlBraceMatcher.java   
public int getBraceTokenGroupId(IElementType tokenType) {
  final Language l = tokenType.getLanguage();
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(l);

  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getLeftBraceType() == tokenType || pair.getRightBraceType() == tokenType ) {
        return l.hashCode();
      }
    }
  }
  if (tokenType instanceof IXmlLeafElementType) {
    return tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER || tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER
           ? XML_VALUE_DELIMITER_GROUP
           : XML_TAG_TOKEN_GROUP;
  }
  else{
    return BraceMatchingUtil.UNDEFINED_TOKEN_GROUP;
  }
}
项目:tools-idea    文件:XmlBraceMatcher.java   
public boolean isStructuralBrace(HighlighterIterator iterator,CharSequence text, FileType fileType) {
  IElementType tokenType = iterator.getTokenType();

  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage());
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if ((pair.getLeftBraceType() == tokenType || pair.getRightBraceType() == tokenType) &&
          pair.isStructural()) return true;
    }
  }
  if (fileType instanceof XmlLikeFileType) {
    return isXmlStructuralBrace(iterator, text, fileType, tokenType);
  }
  return false;
}
项目:consulo-csharp    文件:CSharpDocBraceMatcher.java   
@Override
public IElementType getOppositeBraceTokenType(@NotNull final IElementType type)
{
    PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(type.getLanguage());
    if(matcher != null)
    {
        BracePair[] pairs = matcher.getPairs();
        for(BracePair pair : pairs)
        {
            if(pair.getLeftBraceType() == type)
            {
                return pair.getRightBraceType();
            }
            if(pair.getRightBraceType() == type)
            {
                return pair.getLeftBraceType();
            }
        }
    }
    return null;
}
项目:consulo-play    文件:PlayBaseTemplateBraceMatcher.java   
public PlayBaseTemplateBraceMatcher()
{
    super(new PairedBraceMatcher()
    {
        @Override
        public BracePair[] getPairs()
        {
            return new BracePair[0];
        }

        @Override
        public boolean isPairedBracesAllowedBeforeType(@NotNull IElementType lbraceType, @Nullable IElementType contextType)
        {
            return true;
        }

        @Override
        public int getCodeConstructStart(PsiFile file, int openingBraceOffset)
        {
            return openingBraceOffset;
        }
    }, PlayBaseTemplateLanguage.INSTANCE);
}
项目:consulo    文件:PairedBraceMatcherAdapter.java   
@Override
@Nonnull
public List<IElementType> getOppositeBraceTokenTypes(@Nonnull IElementType type) {
  List<IElementType> result = null;

  for (BracePair pair : myMatcher.getPairs()) {
    IElementType match = null;

    if (type == pair.getRightBraceType()) match = pair.getLeftBraceType();
    if (type == pair.getLeftBraceType()) match = pair.getRightBraceType();

    if (match != null) {
      if (result == null) result = new ArrayList<IElementType>(2);
      result.add(match);
    }
  }

  return result != null ? result : Collections.<IElementType>emptyList();
}
项目:consulo-xml    文件:XmlBraceMatcher.java   
public int getBraceTokenGroupId(IElementType tokenType) {
  final Language l = tokenType.getLanguage();
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(l);

  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getLeftBraceType() == tokenType || pair.getRightBraceType() == tokenType ) {
        return l.hashCode();
      }
    }
  }
  if (tokenType instanceof IXmlLeafElementType) {
    return tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER || tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER
           ? XML_VALUE_DELIMITER_GROUP
           : XML_TAG_TOKEN_GROUP;
  }
  else{
    return BraceMatchingUtil.UNDEFINED_TOKEN_GROUP;
  }
}
项目:consulo-xml    文件:XmlBraceMatcher.java   
public boolean isStructuralBrace(HighlighterIterator iterator,CharSequence text, FileType fileType) {
  IElementType tokenType = iterator.getTokenType();

  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage());
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if ((pair.getLeftBraceType() == tokenType || pair.getRightBraceType() == tokenType) &&
          pair.isStructural()) return true;
    }
  }
  if (fileType instanceof XmlLikeFileType) {
    return isXmlStructuralBrace(iterator, text, fileType, tokenType);
  }
  return false;
}
项目:mule-intellij-plugins    文件:WeavePairedBraceMatcher.java   
@Override
public BracePair[] getPairs() {
    return new BracePair[]{
            new BracePair(WeaveTypes.L_BRACKET, WeaveTypes.R_BRACKET, true),
            new BracePair(WeaveTypes.L_PARREN, WeaveTypes.R_PARREN, true),
            new BracePair(WeaveTypes.L_CURLY, WeaveTypes.R_CURLY, true)
    };
}
项目:smcplugin    文件:SmcPairedBraceMatcher.java   
@Override
public BracePair[] getPairs() {
    return new BracePair[]{
            new BracePair(BRACE_OPEN,BRACE_CLOSE,true),
            new BracePair(BRACKET_OPEN,BRACKET_CLOSE,false),
            new BracePair(PARENTHESES_OPEN,PARENTHESES_CLOSE,false),
            new BracePair(VERBATIM_OPEN,VERBATIM_CLOSE,true),
    };
}
项目:intellij-graphql    文件:GraphQLBraceMatcher.java   
@Override
public BracePair[] getPairs() {
  return new BracePair[]{
      new BracePair(GraphQLElementTypes.PAREN_L, GraphQLElementTypes.PAREN_R, true),
      new BracePair(GraphQLElementTypes.BRACKET_L, GraphQLElementTypes.BRACKET_R, true),
      new BracePair(GraphQLElementTypes.BRACE_L, GraphQLElementTypes.BRACE_R, true)
  };
}
项目:intellij-ce-playground    文件:PairedBraceMatcherAdapter.java   
@Override
public int getBraceTokenGroupId(IElementType tokenType) {
  final BracePair[] pairs = myMatcher.getPairs();
  for (BracePair pair : pairs) {
    if (tokenType == pair.getLeftBraceType() || tokenType == pair.getRightBraceType()) return myLanguage.hashCode();
  }
  return -1;
}
项目:intellij-ce-playground    文件:PairedBraceMatcherAdapter.java   
@Nullable
public BracePair findPair(boolean left, HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
  final IElementType tokenType = iterator.getTokenType();
  final BracePair[] pairs = myMatcher.getPairs();
  for (BracePair pair : pairs) {
    if (tokenType == (left ? pair.getLeftBraceType() : pair.getRightBraceType())) return pair;
  }
  return null;
}
项目:intellij-ce-playground    文件:PairedBraceMatcherAdapter.java   
@Override
public IElementType getOppositeBraceTokenType(@NotNull final IElementType type) {
  final BracePair[] pairs = myMatcher.getPairs();
  for (BracePair pair : pairs) {
    if (type == pair.getRightBraceType()) return pair.getLeftBraceType();
    if (type == pair.getLeftBraceType()) return pair.getRightBraceType();
  }

  return null;
}
项目:intellij-ce-playground    文件:PairedBraceMatcherAdapter.java   
@Override
public boolean isPairBraces(IElementType tokenType, IElementType tokenType2) {
  final BracePair[] pairs = myMatcher.getPairs();
  for (BracePair pair : pairs) {
    if (tokenType == pair.getLeftBraceType() && tokenType2 == pair.getRightBraceType() ||
        tokenType == pair.getRightBraceType() && tokenType2 == pair.getLeftBraceType()) {
      return true;
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:PairedBraceMatcherAdapter.java   
@Override
public boolean isStructuralBrace(HighlighterIterator iterator, CharSequence text, FileType fileType) {
  final IElementType tokenType = iterator.getTokenType();
  final BracePair[] pairs = myMatcher.getPairs();
  for (BracePair pair : pairs) {
    if (tokenType == pair.getRightBraceType() || tokenType == pair.getLeftBraceType()) return pair.isStructural();
  }
  return false;
}
项目:intellij-ce-playground    文件:RegExpBraceMatcher.java   
public BracePair[] getPairs() {
  return new BracePair[]{new BracePair(RegExpTT.GROUP_BEGIN, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.SET_OPTIONS, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.NON_CAPT_GROUP, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.POS_LOOKAHEAD, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.NEG_LOOKAHEAD, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.POS_LOOKBEHIND, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.NEG_LOOKBEHIND, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.PYTHON_NAMED_GROUP, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.PYTHON_NAMED_GROUP_REF, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.RUBY_NAMED_GROUP, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.RUBY_QUOTED_NAMED_GROUP, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.CLASS_BEGIN, RegExpTT.CLASS_END, false), new BracePair(RegExpTT.LBRACE, RegExpTT.RBRACE, false),
    new BracePair(RegExpTT.QUOTE_BEGIN, RegExpTT.QUOTE_END, false),};
}
项目:intellij-ce-playground    文件:XmlBraceMatcher.java   
@Override
public boolean isLBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
  final IElementType tokenType = iterator.getTokenType();
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage());
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getLeftBraceType() == tokenType) return true;
    }
  }
  return tokenType == XmlTokenType.XML_START_TAG_START ||
         tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER ||
         tokenType == XmlTokenType.XML_CDATA_START;
}
项目:intellij-ce-playground    文件:XmlBraceMatcher.java   
@Override
public boolean isRBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
  final IElementType tokenType = iterator.getTokenType();
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage());
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getRightBraceType() == tokenType) return true;
    }
  }

  if (tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END ||
      tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER ||
      tokenType == XmlTokenType.XML_CDATA_END)
  {
    return true;
  }
  else if (tokenType == XmlTokenType.XML_TAG_END) {
    final boolean result = findEndTagStart(iterator);

    if (isFileTypeWithSingleHtmlTags(fileType)) {
      final String tagName = getTagName(fileText, iterator);

      if (tagName != null && HtmlUtil.isSingleHtmlTag(tagName)) {
        return !result;
      }
    }

    return result;
  }
  else {
    return false;
  }
}
项目:intellij-ce-playground    文件:XmlBraceMatcher.java   
@Override
public boolean isPairBraces(IElementType tokenType1, IElementType tokenType2) {
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType1.getLanguage());
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getLeftBraceType() == tokenType1 ) return pair.getRightBraceType() == tokenType2;
      if (pair.getRightBraceType() == tokenType1 ) return pair.getLeftBraceType() == tokenType2;
    }
  }
  if (tokenType2.equals(PAIRING_TOKENS.get(tokenType1))) return true;
  List<IElementType> keys = PAIRING_TOKENS.getKeysByValue(tokenType1);
  return keys != null && keys.contains(tokenType2);
}
项目:intellij-ce-playground    文件:XmlBraceMatcher.java   
@Override
public IElementType getOppositeBraceTokenType(@NotNull final IElementType type) {
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(type.getLanguage());
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getLeftBraceType() == type ) return pair.getRightBraceType();
      if (pair.getRightBraceType() == type ) return pair.getLeftBraceType();
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:RngCompactLanguage.java   
@Override
public BracePair[] getPairs() {
  if (myBracePairs == null) {
    myBracePairs = new BracePair[]{
            new BracePair(RncTokenTypes.LBRACE, RncTokenTypes.RBRACE, true),
            new BracePair(RncTokenTypes.LPAREN, RncTokenTypes.RPAREN, false),
            new BracePair(RncTokenTypes.LBRACKET, RncTokenTypes.RBRACKET, false),
    };
  }
  return myBracePairs;
}
项目:intellij-ce-playground    文件:DbPairedBraceMatcher.java   
public DbPairedBraceMatcher() {
  super(new PairedBraceMatcher() {
    @Override
    public BracePair[] getPairs() {
      return BRACE_PAIRS;
    }

    @Override
    public boolean isPairedBracesAllowedBeforeType(@NotNull IElementType lbraceType, @Nullable IElementType contextType) {
      // TODO: improve this.
      return true;
    }

    @Override
    public int getCodeConstructStart(PsiFile file, int openingBraceOffset) {
      PsiElement element = file.findElementAt(openingBraceOffset);
      if (element == null || element instanceof PsiFile) {
        return openingBraceOffset;
      }
      PsiElement parent = element.getParent();
      if (parent instanceof PsiDbCastExpr || parent instanceof PsiDbParenExpr) {
        return openingBraceOffset;
      }
      if (parent instanceof PsiDbMethodExpr) {
        return parent.getTextRange().getStartOffset();
      }
      if (parent instanceof PsiDbResourceParameters) {
        parent = parent.getParent();
        if (parent instanceof PsiDbResourcesExpr) {
          return parent.getTextRange().getStartOffset();
        }
      }
      return openingBraceOffset;
    }
  }, DbLanguage.INSTANCE);
}
项目:intellij-ce-playground    文件:XPathLanguage.java   
@Override
public BracePair[] getPairs() {
    if (myBracePairs == null) {
        myBracePairs = new BracePair[]{
                new BracePair(XPathTokenTypes.LPAREN, XPathTokenTypes.RPAREN, false),
                new BracePair(XPathTokenTypes.LBRACKET, XPathTokenTypes.RBRACKET, false),
        };
    }
    return myBracePairs;
}
项目:graphql-intellij-plugin    文件:GraphQLPairedBraceMatcher.java   
@Override
public BracePair[] getPairs() {
    return new BracePair[]{
            new BracePair(GraphQLTypes.BRACE1, GraphQLTypes.BRACE2, true),
            new BracePair(GraphQLTypes.PAREN1, GraphQLTypes.PAREN2, false),
            new BracePair(GraphQLTypes.BRACKET1, GraphQLTypes.BRACKET2, false)
    };
}
项目:intellij-avro    文件:AvroIdlPairedBraceMatcher.java   
@Override
public BracePair[] getPairs() {
    return new BracePair[] {
            new BracePair(AvroIdlTypes.LEFT_BRACE, AvroIdlTypes.RIGHT_BRACE, true),
            new BracePair(AvroIdlTypes.LEFT_BRACKET, AvroIdlTypes.RIGHT_BRACKET, false),
            new BracePair(AvroIdlTypes.LEFT_PAREN, AvroIdlTypes.LEFT_PAREN, false),
            new BracePair(AvroIdlTypes.LEFT_ANGLE, AvroIdlTypes.RIGHT_ANGLE, false)
    };
}
项目:tools-idea    文件:PairedBraceMatcherAdapter.java   
@Override
public int getBraceTokenGroupId(IElementType tokenType) {
  final BracePair[] pairs = myMatcher.getPairs();
  for (BracePair pair : pairs) {
    if (tokenType == pair.getLeftBraceType() || tokenType == pair.getRightBraceType()) return myLanguage.hashCode();
  }
  return -1;
}
项目:tools-idea    文件:PairedBraceMatcherAdapter.java   
@Nullable
public BracePair findPair(boolean left, HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
  final IElementType tokenType = iterator.getTokenType();
  final BracePair[] pairs = myMatcher.getPairs();
  for (BracePair pair : pairs) {
    if (tokenType == (left ? pair.getLeftBraceType() : pair.getRightBraceType())) return pair;
  }
  return null;
}
项目:tools-idea    文件:PairedBraceMatcherAdapter.java   
@Override
public IElementType getOppositeBraceTokenType(@NotNull final IElementType type) {
  final BracePair[] pairs = myMatcher.getPairs();
  for (BracePair pair : pairs) {
    if (type == pair.getRightBraceType()) return pair.getLeftBraceType();
    if (type == pair.getLeftBraceType()) return pair.getRightBraceType();
  }

  return null;
}
项目:tools-idea    文件:PairedBraceMatcherAdapter.java   
@Override
public boolean isPairBraces(IElementType tokenType, IElementType tokenType2) {
  final BracePair[] pairs = myMatcher.getPairs();
  for (BracePair pair : pairs) {
    if (tokenType == pair.getLeftBraceType() && tokenType2 == pair.getRightBraceType() ||
        tokenType == pair.getRightBraceType() && tokenType2 == pair.getLeftBraceType()) {
      return true;
    }
  }
  return false;
}
项目:tools-idea    文件:PairedBraceMatcherAdapter.java   
@Override
public boolean isStructuralBrace(HighlighterIterator iterator, CharSequence text, FileType fileType) {
  final IElementType tokenType = iterator.getTokenType();
  final BracePair[] pairs = myMatcher.getPairs();
  for (BracePair pair : pairs) {
    if (tokenType == pair.getRightBraceType() || tokenType == pair.getLeftBraceType()) return pair.isStructural();
  }
  return false;
}
项目:tools-idea    文件:RegExpBraceMatcher.java   
public BracePair[] getPairs() {
  return new BracePair[]{new BracePair(RegExpTT.GROUP_BEGIN, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.SET_OPTIONS, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.NON_CAPT_GROUP, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.POS_LOOKAHEAD, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.NEG_LOOKAHEAD, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.POS_LOOKBEHIND, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.NEG_LOOKBEHIND, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.PYTHON_NAMED_GROUP, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.PYTHON_NAMED_GROUP_REF, RegExpTT.GROUP_END, true),
    new BracePair(RegExpTT.CLASS_BEGIN, RegExpTT.CLASS_END, false), new BracePair(RegExpTT.LBRACE, RegExpTT.RBRACE, false),
    new BracePair(RegExpTT.QUOTE_BEGIN, RegExpTT.QUOTE_END, false),};
}
项目:tools-idea    文件:XmlBraceMatcher.java   
public boolean isLBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
  final IElementType tokenType = iterator.getTokenType();
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage());
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getLeftBraceType() == tokenType) return true;
    }
  }
  return tokenType == XmlTokenType.XML_START_TAG_START ||
         tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER ||
         tokenType == XmlTokenType.XML_CDATA_START;
}
项目:tools-idea    文件:XmlBraceMatcher.java   
public boolean isRBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
  final IElementType tokenType = iterator.getTokenType();
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage());
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getRightBraceType() == tokenType) return true;
    }
  }

  if (tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END ||
      tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER ||
      tokenType == XmlTokenType.XML_CDATA_END)
  {
    return true;
  }
  else if (tokenType == XmlTokenType.XML_TAG_END) {
    final boolean result = findEndTagStart(iterator);

    if (isFileTypeWithSingleHtmlTags(fileType)) {
      final String tagName = getTagName(fileText, iterator);

      if (tagName != null && HtmlUtil.isSingleHtmlTag(tagName)) {
        return !result;
      }
    }

    return result;
  }
  else {
    return false;
  }
}
项目:tools-idea    文件:XmlBraceMatcher.java   
public boolean isPairBraces(IElementType tokenType1, IElementType tokenType2) {
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType1.getLanguage());
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getLeftBraceType() == tokenType1 ) return pair.getRightBraceType() == tokenType2;
      if (pair.getRightBraceType() == tokenType1 ) return pair.getLeftBraceType() == tokenType2;
    }
  }
  if (tokenType2.equals(PAIRING_TOKENS.get(tokenType1))) return true;
  List<IElementType> keys = PAIRING_TOKENS.getKeysByValue(tokenType1);
  return keys != null && keys.contains(tokenType2);
}
项目:tools-idea    文件:XmlBraceMatcher.java   
public IElementType getOppositeBraceTokenType(@NotNull final IElementType type) {
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(type.getLanguage());
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getLeftBraceType() == type ) return pair.getRightBraceType();
      if (pair.getRightBraceType() == type ) return pair.getLeftBraceType();
    }
  }
  return null;
}