com.intellij.lang.BracePair Java Examples

The following examples show how to use com.intellij.lang.BracePair. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CSharpDocBraceMatcher.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Override
public IElementType getOppositeBraceTokenType(@Nonnull 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;
}
 
Example #2
Source File: PairedBraceMatcherAdapter.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #3
Source File: PairedBraceMatcherAdapter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public IElementType getOppositeBraceTokenType(@Nonnull 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;
}
 
Example #4
Source File: GraphQLBraceMatcher.java    From js-graphql-intellij-plugin with MIT License 5 votes vote down vote up
@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)
  };
}
 
Example #5
Source File: ANTLRv4BraceMatcher.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
@Override
public BracePair[] getPairs() {
	return new BracePair[] {
			new BracePair(getTokenElementType(LPAREN), getTokenElementType(RPAREN), false),
			new BracePair(getTokenElementType(OPTIONS), getTokenElementType(RBRACE), true),
			new BracePair(getTokenElementType(TOKENS), getTokenElementType(RBRACE), true),
			new BracePair(getTokenElementType(CHANNELS), getTokenElementType(RBRACE), true),
			new BracePair(getTokenElementType(BEGIN_ACTION), getTokenElementType(END_ACTION), false),
			new BracePair(getTokenElementType(BEGIN_ARGUMENT), getTokenElementType(END_ARGUMENT), false),
			new BracePair(getTokenElementType(LT), getTokenElementType(GT), false),
	};
}
 
Example #6
Source File: PairedBraceMatcherAdapter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #7
Source File: PairedBraceMatcherAdapter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #8
Source File: WeavePairedBraceMatcher.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@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)
    };
}
 
Example #9
Source File: PairedBraceMatcherAdapter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #10
Source File: PairedBraceMatcherAdapter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #11
Source File: FluidBraceMatcher.java    From idea-php-typo3-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public BracePair[] getPairs() {
    return new BracePair[]{
        new BracePair(FluidTypes.LEFT_PARENTH, FluidTypes.RIGHT_PARENTH, false),
        new BracePair(FluidTypes.EXPR_START, FluidTypes.EXPR_END, true),
    };
}
 
Example #12
Source File: ThriftBraceMatcher.java    From intellij-thrift with Apache License 2.0 4 votes vote down vote up
@Override
public BracePair[] getPairs() {
  return PAIRS;
}
 
Example #13
Source File: GLSLPairedBraceMatcher.java    From glsl4idea with GNU Lesser General Public License v3.0 4 votes vote down vote up
@NotNull
public BracePair[] getPairs() {
    return bracePairs;
}
 
Example #14
Source File: CSharpDocBraceMatcher.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@Override
public BracePair[] getPairs()
{
	return new BracePair[0];
}
 
Example #15
Source File: LatteBraceMatcher.java    From intellij-latte with MIT License 4 votes vote down vote up
@NotNull
@Override
public BracePair[] getPairs() {
    return PAIRS;
}
 
Example #16
Source File: PairMatcher.java    From Intellij-Plugin with Apache License 2.0 4 votes vote down vote up
@Override
public BracePair[] getPairs() {
    return pairs;
}
 
Example #17
Source File: CSharpPairedBraceMatcher.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@Override
public BracePair[] getPairs()
{
	return ourPairs;
}
 
Example #18
Source File: HaskellBraceMatcher.java    From intellij-haskforce with Apache License 2.0 4 votes vote down vote up
@Override
public BracePair[] getPairs() {
    return PAIRS;
}
 
Example #19
Source File: HaxeBraceMatcher.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
@Override
public BracePair[] getPairs() {
  return PAIRS;
}
 
Example #20
Source File: XQueryBraceMatcher.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
@Override
public BracePair[] getPairs() {
    return PAIRS;
}
 
Example #21
Source File: BuckBraceMatcher.java    From buck with Apache License 2.0 4 votes vote down vote up
@Override
public BracePair[] getPairs() {
  return PAIRS;
}
 
Example #22
Source File: CGBraceMatcher.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Override
public BracePair[] getPairs()
{
	return ourPairs;
}
 
Example #23
Source File: CustomFileTypeBraceMatcher.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public BracePair[] getPairs() {
  return PAIRS;
}
 
Example #24
Source File: CustomFileTypeBraceMatcher.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static boolean isRBraceToken(IElementType type) {
  for (BracePair pair : PAIRS) {
    if (type == pair.getRightBraceType()) return true;
  }
  return false;
}
 
Example #25
Source File: CppBraceMatcher.java    From CppTools with Apache License 2.0 4 votes vote down vote up
public BracePair[] getPairs() {
  return PAIRS;
}
 
Example #26
Source File: ElmPairedBraceMatcher.java    From elm-plugin with MIT License 4 votes vote down vote up
@Override
public BracePair[] getPairs() {
    return PAIRS;
}
 
Example #27
Source File: NASMPairedBraceMatcher.java    From JetBrains-NASM-Language with MIT License 4 votes vote down vote up
@NotNull
@Override
public BracePair[] getPairs() {
    return BRACE_PAIRS;
}
 
Example #28
Source File: DunePairedBraceMatcher.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
@NotNull
@Override
public BracePair[] getPairs() {
    return PAIRS;
}
 
Example #29
Source File: OclPairedBraceMatcher.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
@NotNull
@Override
public BracePair[] getPairs() {
    return PAIRS;
}
 
Example #30
Source File: RmlPairedBraceMatcher.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
@NotNull
@Override
public BracePair[] getPairs() {
    return PAIRS;
}