-
Notifications
You must be signed in to change notification settings - Fork 4
/
USDBraceMatcher.java
35 lines (28 loc) · 1.03 KB
/
USDBraceMatcher.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.justint.usdidea.codeinsight.highlighting;
import com.intellij.lang.BracePair;
import com.intellij.lang.PairedBraceMatcher;
import com.intellij.psi.PsiFile;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static com.justint.usdidea.lang.psi.USDTypes.*;
public class USDBraceMatcher implements PairedBraceMatcher {
private static final BracePair[] PAIRS = new BracePair[] {
new BracePair(LEFTBRACE, RIGHTBRACE, true),
new BracePair(LEFTPARENS, RIGHTPARENS, true),
new BracePair(LEFTBRACKET, RIGHTBRACKET, false)
};
@NotNull
@Override
public BracePair[] getPairs() {
return PAIRS;
}
@Override
public boolean isPairedBracesAllowedBeforeType(@NotNull IElementType lBraceType, @Nullable IElementType contextType) {
return true;
}
@Override
public int getCodeConstructStart(PsiFile file, int openingBraceOffset) {
return openingBraceOffset;
}
}